Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String url="jdbc:mysql://localhost:3306/test";
- Connection con = DriverManager.getConnection( url, "cb0", "xxx" );
- Conn = DriverManager.getConnection
- ("jdbc:mysql://localhost/?user=root&password=rootpassword");
- s=Conn.createStatement();
- int Result=s.executeUpdate("CREATE DATABASE databasename");
- //these are variables i declare in the beginning of my code
- public static final String DRIVER = "com.mysql.jdbc.Driver";
- public static final String DATABASE_URL = "jdbc:mysql://localhost:3306/jtschema";
- private Connection connection = null;
- public static Statement statement = null;
- public void initSQLServer() {
- try {
- Class.forName(DRIVER).newInstance();
- try {
- connection = DriverManager.getConnection(DATABASE_URL, "root", "Dropatrain!248");
- statement = connection.createStatement();
- } catch (SQLException e) {
- System.out.println("SQLException: " + e.getMessage());
- System.out.println("SQLState: " + e.getSQLState());
- System.out.println("VendorError: " + e.getErrorCode());
- }
- } catch (Exception ex) {
- System.out.println(ex);
- }
Add Comment
Please, Sign In to add comment