Sunday, December 23, 2012

Creating connection to the MySQL database

4:45 AM


import java.sql.Connection;
import java.sql.DriverManager;

public class Main {
  public static void main(String[] argvthrows Exception {
    String driverName = "org.gjt.mm.mysql.Driver";
    Class.forName(driverName);

    String serverName = "localhost";
    String mydatabase = "mydatabase";
    String url = "jdbc:mysql :// " + serverName + "/" + mydatabase; 
                                                                    
    String username = "username";
    String password = "password";
    Connection connection = DriverManager.getConnection(url, username, password);
  }
}

Written by

We are one of the initiators of the development of information technology in understanding the need for a solution that is familiar and close to us.

0 comments:

Post a Comment

 

© 2013 Klick Dev. All rights resevered.

Back To Top