Guest User

Untitled

a guest
Jun 24th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. String url="jdbc:mysql://localhost:3306/test";
  2.  
  3. Connection con = DriverManager.getConnection( url, "cb0", "xxx" );
  4.  
  5. Conn = DriverManager.getConnection
  6. ("jdbc:mysql://localhost/?user=root&password=rootpassword");
  7. s=Conn.createStatement();
  8. int Result=s.executeUpdate("CREATE DATABASE databasename");
  9.  
  10. //these are variables i declare in the beginning of my code
  11. public static final String DRIVER = "com.mysql.jdbc.Driver";
  12. public static final String DATABASE_URL = "jdbc:mysql://localhost:3306/jtschema";
  13. private Connection connection = null;
  14. public static Statement statement = null;
  15.  
  16.  
  17. public void initSQLServer() {
  18. try {
  19. Class.forName(DRIVER).newInstance();
  20. try {
  21. connection = DriverManager.getConnection(DATABASE_URL, "root", "Dropatrain!248");
  22. statement = connection.createStatement();
  23. } catch (SQLException e) {
  24. System.out.println("SQLException: " + e.getMessage());
  25. System.out.println("SQLState: " + e.getSQLState());
  26. System.out.println("VendorError: " + e.getErrorCode());
  27. }
  28. } catch (Exception ex) {
  29. System.out.println(ex);
  30. }
Add Comment
Please, Sign In to add comment