hi
I want to make connection to access database from jsp with dynamically
but when i used following code then it is not working> is there anybody can help me?
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<title>JSP Example 2</title>
</head>
<body>
<h1>JSP Example 3</h1>
<%
Connection dbcon;
ResultSet result;
PreparedStatement pstm;
String id ;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ=database/data.mdb";
dbcon=DriverManager.getConnection(url);
id = request.getParameter("Id");
pstm =dbcon.prepareStatement("select * from t_data");
result=pstm.executeQuery();
boolean value =result.next();
if (value!=false){
out.println("<table border=1>");
do{
String ID=result.getString("ID");
String name = result.getString("Name");
String city = result.getString("City");
out.println("<tr><td>" + name);
out.println("<td>" + city);
out.println("</td>");
out.println("<td>"+ID);
out.println("</td>");
out.println("</tr>");
}while(result.next());
}
out.println("</table>");
}
catch(ClassNotFoundException cnf){
out.println("Database error");
}
%>
</body>
</html>
but when i use following line then then above code is working good
String url="jdbc:odbc:data";
can anyone give me the solution.
Thanks
Bina