connect java application with mysql [message #473834] |
Wed, 01 September 2010 01:15 |
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
|
|
|
|
|