Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC connection to MS Access

 
gaurav chhabra
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sir i want to connect jsp with MS-Access
the code is--------

<!-- jai shri ram -->
<html>
<head><title>JAI SHRI RAM</title></head>

<body>
<%@ page import="java.sql.*" %>
<%
String user1 = null;
String pass1 = null;
ResultSet rs = null;
Statement st = null;
Connection conn = null;
try
{

String url = "jdbc dbc:lala" ;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn = DriverManager.getConnection(url,"","");
st = conn.createStatement();
rs = st.executeQuery("select * from ram1");
while(rs.next() )
{
System.err.println( rs.getString("name") );
System.out.println(rs.getString("password"));

user1 = rs.getString("name");
pass1 = rs.getString("name");
out.println(user1+" "+pass1);
}
}
catch(Exception e)
{
out.println("there is an error");
}
out.println("jai shri ram");
%>
</body></html>

but it is giving an error as it is going into catch block.......
please help me out..it is veru necessary
thankyou
gurav
 
Rajendar Goud
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gaurav
The catch statements you used doesnt help you conclude anything what the error is about. provide some meaning ful catch statements and if possible print the stack to find what the actual error is.
As of the connection to access,
did u created the DSN named 'lala' in the ODBC32 of windows? if not ,do check it and create either a System or File dsn named 'lala' and then test the application.

Raj
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic