jQuery in Action, 3rd edition
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 Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » JSP
Reply locked New topic

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 -->
<head><title>JAI SHRI RAM</title></head>

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

String url = "jdbc dbc:lala" ;
conn = DriverManager.getConnection(url,"","");
st = conn.createStatement();
rs = st.executeQuery("select * from ram1");
while(rs.next() )
System.err.println( rs.getString("name") );

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");

but it is giving an error as it is going into catch block.......
please help me out..it is veru necessary
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

Joined: Jan 10, 2002
Posts: 63348

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
It's not a secret anymore!