This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes JSP and the fly likes Error while connecting to database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » JSP
Reply locked New topic
Author

Error while connecting to database

gaurav chhabra
Ranch Hand

Joined: Jul 24, 2004
Posts: 109
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
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
duplicate of http://www.coderanch.com/t/301770/JDBC/java/JDBC-connection-MS-Access
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61448
    
  67

Please do not cross-post the same question in multiple forums.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error while connecting to database