<分区>
这段代码连接abd创建了一个数据库,如何选择创建的数据库来使用它?
public class Connect {
public static void main(String[] args) {
Connection connection = null;
try {
Class.forName("org.postgresql.Driver");
connection = DriverManager.getConnection(
"jdbc:postgresql://localhost:5432/","postgres", "12345");
Statement statement = connection.createStatement();
statement.execute("CREATE DATABASE mydb");
//now I hav to connect to mydb
connection.close();
} catch (ClassNotFoundException ex) {
Logger.getLogger(OracleToPostgres.class.getName()).log(Level.SEVERE, null, ex);
} catch (SQLException ex) {
Logger.getLogger(OracleToPostgres.class.getName()).log(Level.SEVERE, null, ex);
}
}
}