How can I connect to mysql database using jdbc?

Luigi Viggiano

Use something like:


    // loads the JDBC driver
    Class.forName("org.gjt.mm.mysql.Driver").newInstance();
    // get a database connection
    Connection conn = DriverManager.getConnection(
        "jdbc:mysql://hostname/databaseName", 
        "user",
        "password");
obviously the JDBC driver "org.gjt.mm.mysql.Driver" must be in classpath. You can download it from here.
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact