Guest User

Untitled

a guest
Feb 19th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. public static void main(String[] args) {
  2. Connection connection = null;
  3. try {
  4.  
  5. Class.forName("org.postgresql.Driver");
  6. connection = DriverManager.getConnection(
  7. "jdbc:postgresql://localhost:5432/","postgres", "12345");
  8.  
  9.  
  10. Statement statement = connection.createStatement();
  11. statement.execute("CREATE DATABASE mydb");
  12. //now I hav to connect to mydb
  13.  
  14. connection.close();
  15. } catch (ClassNotFoundException ex) {
  16. Logger.getLogger(OracleToPostgres.class.getName()).log(Level.SEVERE, null, ex);
  17. }catch (SQLException ex) {
  18. Logger.getLogger(OracleToPostgres.class.getName()).log(Level.SEVERE, null, ex);
  19. }
  20. }
Add Comment
Please, Sign In to add comment