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: 21805
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: Mon Mar 18 21:39:31 CDT 2024