Explore your Imagination

Blog of Joeby Zaldivar Keep in touch…


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 {
      con = DriverManager.getConnection("jdbc:mysql://localhost/selectedDb",
        dbUSer, dbPwd);

        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


No trackbacks yet.