Friday, March 30, 2012

how to create a connecction in mysql jsp?

How to create mysql connectiion using jsp?

Ans:-
Creating connection using mysql,jsp

<%@ page language="java" import="java.sql.*" %>


<%
Connection con = null;
String databaseDriver = "com.mysql.jdbc.Driver";
String connectionURL="";


try {
connectionURL = "jdbc:mysql://localhost:3306/DataBaseName";
Class.forName(databaseDriver).newInstance();

con = DriverManager.getConnection(connectionURL, "username", "password");

}catch(Exception e){
out.print("Please wait 'http://rajdeokumarsingh1.blogspot.in/' will be back soon ");
}

%>

ow wait before doing this you have to put mySqlConnector.jar in lib folder of jdkx.xx.Ok

Doooooooooooooooooooooooooooooone!!!!!!!!!!!!!!!

you can download mySqlConnector.jar from this site
http://dev.mysql.com/downloads/connector/j/3.1.html

Extract it and paste on lib folder that's it


Now you done it

Thanks

No comments:

Post a Comment