Home » Open Source » MySQL » connect java application with mysql
connect java application with mysql [message #473834] Wed, 01 September 2010 01:15 Go to next message
sathishraj
Messages: 53
Registered: July 2010
Location: chennai
Member
Hi everyone please give me solution for the below one.
How to connect java application with the mysql database. i tried the following steps:
 Connection con = null;
    String url = "jdbc:mysql://localhost:3306/";
    String db = "leavedatabase";
    String driver = "com.mysql.jdbc.Driver";
    String user = "root";
    String pass = "";
    try{
      Class.forName(driver);
      con = DriverManager.getConnection(url+db, user, pass);
      Statement st = con.createStatement();
      ResultSet res = st.executeQuery("SELECT * FROM  employee");
      while (res.next()) {
        String employeeName = res.getString("name");
        System.out.println(employeeName);
      }
      con.close();


but here the problem is with the driver.

[Updated on: Wed, 01 September 2010 01:15]

Report message to a moderator

Re: connect java application with mysql [message #473837 is a reply to message #473834] Wed, 01 September 2010 01:25 Go to previous messageGo to next message
Littlefoot
Messages: 19885
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
With MySQL? But, this is an Oracle forum; perhaps you should ask the question on one of MySQL forums, instead?

However, if the problem manifests the same way on both databases, you might still get the answer here. I'd help if I knew, but - unfortunately - I don't.
Re: connect java application with mysql [message #473838 is a reply to message #473837] Wed, 01 September 2010 01:27 Go to previous message
sathishraj
Messages: 53
Registered: July 2010
Location: chennai
Member
thanks for your response.

[Updated on: Wed, 01 September 2010 01:31]

Report message to a moderator

Previous Topic: mysql to oracle
Next Topic: MySQL to SQL
Goto Forum:
  


Current Time: Thu Dec 18 18:08:01 CST 2014

Total time taken to generate the page: 0.10912 seconds