Click here to Skip to main content
15,886,729 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
when i try to connect java application with database (Mysql) i have problem to connect with mysql but not showing any error or exceptions .

Code :
Java
try{

Class.forName("com.mysql.jdbc.Driver");
String url ="jdbc:mysql://localhost:3306/clas";
System.out.println("step1 ");
Connection con = DriverManager.getConnection(url,"root", "aaaa");
System.out.println("step2"); 
Statement st=con.createStatement();

}catch(Exception e)
{
System.out.println("Error "+e); 
}

output :
step1

connection is not created ...communication link is correct
Posted
Updated 4-Nov-15 23:03pm
v2
Comments
Richard MacCutchan 5-Nov-15 5:30am    
Check the url is correct.
M.FarrukhFaizy 6-Nov-15 6:58am    
Have you download mysql-java connector ? if yes then put this in your project library folder and then run , Although you have no error in script above

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900