Hi ,
I am usinga code to connect to database. here is the code--
<html>
<head>
<title>Obtaining a Connection</title>
</head>
<body>
<h1>This Page Obtains a Connection to a Database and executes a query</h1>
<%
Connection conn = null;
ResultSet result = null;
Statement stmt = null;
try {
Class c = Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch (Exception e) {
System.out.println("Error occurred " + e);
}
try {
conn = DriverManager.getConnection("jdbc:odbc:namish") ;
}
catch (SQLException e) {
System.out.println("Error occurred " + e);
}
try {
stmt = conn.createStatement();
result = stmt.executeQuery("SELECT * FROM ARUSER; ");
}
catch (SQLException e) {
System.out.println("Error occurred " + e);
}
%>
when i am trying to run this i am getting null pointer exception error.
can you please help me in rectifying this problem. I have created a DSN name namish and using that.it is the right way to do it or any other way i should proceed..
Thanks
NT