String sql2 = "create database ?";
String url = "jdbc:mysql://localhost:3306/information_schema";
try {
Class.forName( "org.gjt.mm.mysql.Driver" );
java.sql.Connection conn1=DriverManager.getConnection(url, username, password);
PreparedStatement pstmt=conn1.prepareStatement(sql2);
pstmt.setString(1, database1);
System.out.println("aa");
}catch ( ClassNotFoundException cnfex ) {
System.err.println( "装载 JDBC/ODBC 驱动程序失败。" );
cnfex.printStackTrace();
System.exit( 1 ); // terminate program
}
catch ( SQLException sqlex ) {
System.err.println( "无法连接数据库" );
sqlex.printStackTrace();
System.exit( 1 ); // terminate program
} 这样一个程序,可以完全执行一次.可是就是不知道创建的数据库去那了...数据库还没有创建成功...
如果加上pstmt.executeUpdate();,他就会提醒无法连接数据库..
String url = "jdbc:mysql://localhost:3306/information_schema";
try {
Class.forName( "org.gjt.mm.mysql.Driver" );
java.sql.Connection conn1=DriverManager.getConnection(url, username, password);
PreparedStatement pstmt=conn1.prepareStatement(sql2);
pstmt.setString(1, database1);
System.out.println("aa");
}catch ( ClassNotFoundException cnfex ) {
System.err.println( "装载 JDBC/ODBC 驱动程序失败。" );
cnfex.printStackTrace();
System.exit( 1 ); // terminate program
}
catch ( SQLException sqlex ) {
System.err.println( "无法连接数据库" );
sqlex.printStackTrace();
System.exit( 1 ); // terminate program
} 这样一个程序,可以完全执行一次.可是就是不知道创建的数据库去那了...数据库还没有创建成功...
如果加上pstmt.executeUpdate();,他就会提醒无法连接数据库..
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货