Tag: sp execuql

使用Mysql中的executeUpdate通过sql语句创建表

我有以下doGet() : protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { MysqlDataSource ds = new MysqlConnectionPoolDataSource(); ds.setServerName(“localhost”); ds.setPort(3306); ds.setUser(“root”); ds.setPassword(“”); try { Connection connection = null ; connection = ds.getConnection(); Statement statement = connection.createStatement(); // create the DB .. statement.executeUpdate(“CREATE DATABASE IF NOT EXISTS ” +”testSQLtable” ) ; // use DB .. statement.executeUpdate(“USE testSQLtable”) […]