Explore your Imagination
Free Hosting

Free Web Hosting with PHP, MySQL, Apache, FTP and more.
Get your Free SubDOMAIN you.6te.net or you.eu5.org or...
Create your account NOW at http://www.freewebhostingarea.com.

Cheap Domains

Cheap Domains
starting at $2.99/year

check

Blog of Joeby Zaldivar Keep in touch…

4May/115

Connect Java to MYSQL using JDBC


Most of the System requires a back end in order to save the transactions. Here is the sample how to connect your java apps into mysql database.

import java.sql.*
public class MysqlConnect{
Connection con = null;
String dbUser = "root";
String dbPwd = "password";
String selectedDb = "test";

 try {
      Class.forName("com.mysql.jdbc.Driver").newInstance();
      con = DriverManager.getConnection("jdbc:mysql://localhost/selectedDb",
        dbUSer, dbPwd);

      if(!con.isClosed())
        System.out.println("Successfully connected to " +
          "MySQL server using TCP/IP...");

    } catch(Exception e) {
      System.err.println("Exception: " + e.getMessage());
    }
}

Comments (5) Trackbacks (0)
  1. thanks i helps a lot to my web apps..

  2. good website. i like all pages and all comments. thanks for all!!! regards!!!http://www.calculadoradocidadao.com

  3. i think this subject is not very clear for me, can you explain it better please. thanks.http://www.pagode2011.com


Leave a comment

(required)

No trackbacks yet.