Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try {
- Statement stmt;
- //Register the JDBC driver for MySQL.
- Class.forName("com.mysql.jdbc.Driver");
- //Define URL of database server for
- // database named mysql on the localhost
- // with the default port number 3306.
- String url =
- "jdbc:mysql://localhost:3306/mysql";
- //Get a connection to the database for a
- // user named root with a blank password.
- // This user is the default administrator
- // having full privileges to do anything.
- Connection con =
- DriverManager.getConnection(
- url,"root", "samurai87");
- //Display URL and connection information
- System.out.println("URL: " + url);
- System.out.println("Connection: " + con);
- //Get a Statement object
- stmt = con.createStatement();
- // stmt.executeUpdate(
- con.close();
- }catch( Exception e ) {
- e.printStackTrace();
- }//end catch
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement