Download connector/j Jar file Copy and Paste java->jdk->jre->ext->lib Folder folder.
create a mysqlconnection.jsp file
<%@ page language="java" import="java.sql.*" %>
<%
Connection con = null;
Statement stmt =null;
ResultSet rs = null;
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection("jdbc:mysql:mysql_databsename","mysql_username", "mysql_password");
stmt = con.createStatement();
rs = stmt.executeQuery("SELECT * FROM tab");
while (rs.next())
{
out.println(rs.getString("field"));
}
rs.close();
}
catch (SQLException ex)
{
//Catch Errors
out.println("SQLException: " + ex.getMessage());
out.println("SQLState: " + ex.getSQLState());
out.println("VendorError: " + ex.getErrorCode());
}
%>
Friday, April 2, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment