Saturday, May 8, 2010

Java: MYSQL -JDBC connection

To connect Java with MYSQL you can use bellow code but before using this code you have to download MYSQL-java Connector
Download MYSQL-JAVA Connector
Put this jar file in lib directory of your project

String url ="jdbc:mysql://localhost:"+Port+"/"+Db;
cn =DriverManager.getConnection(url,Host,Pw);
catch(Exception e)
return e+": Error in Connection";
return "OK";

No comments:

Post a Comment