Subject | jdbc connectivity to firebird by servlet through tomcat 4.1 |
---|---|
Author | Sudarshan Wad <sudan5757@yahoo.com> |
Post date | 2003-02-27T08:48:22Z |
hi,
I am new in this group.I am using firebird database and database
is stored at
C:\users\calypso\database\CALYPSODB.GDB
I have written a simple servlet to coonect to my database and
retrieve some data.
I have stored the following files
firebirdsql.jar
log4j-core.jar
mini-j2ee.jar
mini-concurrent.jar
jass.jar
firebirdjmx.jar
firebirdsql-test.jar
in C:\calsoft\j2sdk\jre\lib\ext directory
My classpath is:-
C:\calsoft\j2sdk\lib\servlet.jar;C:\calsoft\j2sdk\jre\lib
Now i am trying to run my servlet i am getting an error
class java.lang.ClassNotFoundException class
java.lang.NullPointerException
I want to know wheather any chnages needed at apachi server side.
my code is
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.net.*;
import java.sql.*;
// create class inheritting from HttpServlet
public class firetest2 extends HttpServlet
{
PrintWriter pw;
Connection con;
String q;
String temp="good connection";
//------------------------init-------------------------------
public void init(ServletConfig config)throws ServletException
{
super.init(config);
try
{
Class.forName("org.firebirdsql.jdbc.FBDriver");
con = DriverManager.getConnection
("jdbc:firebirdsql:Archie.ncst.ernet.in/3050:c:\\users\\calypso\\datab
ase\\CALYPSODB.gdb","SYSDBA","masterkey");
} }
catch(ClassNotFoundException e)
{
temp=e.getClass().toString();
}
catch(SQLException e)
{
temp=e.getClass().toString();
}
}
//----------------------------doGet()---------------------------------
----------------
public void doGet(HttpServletRequest req,HttpServletResponse
res)
throws ServletException,IOException
{
res.setContentType("text/html");
pw=res.getWriter();
pw.println("<html>");
pw.println("<body>");
try
{
ResultSet rs;
pw.println(temp);
pw.println("inside doGet");
Statement stmt = con.createStatement
();
pw.println("after statement");
/* q ="select * from ROLEINFO;";
rs = stmt.executeQuery(q);
pw.println("outside loop");
if(rs.first())
{
pw.println("inside");
String key;
if(rs!=null)
{
do
{
key =rs.getString("ID");
pw.println("ID ="+key+" ");
key = rs.getString("NAME");
pw.print(" name = "+key+" ");
}while(rs.next());
}
}
else
{
pw.println("outside");
}
*/
}
catch(Exception e){
pw.println(e.getClass().toString());
}
pw.println("</body>");
pw.println("</html>");
}
//--------------------------------------------------------------------
----------------
}
please reply as soon as possible
sudarshan
I am new in this group.I am using firebird database and database
is stored at
C:\users\calypso\database\CALYPSODB.GDB
I have written a simple servlet to coonect to my database and
retrieve some data.
I have stored the following files
firebirdsql.jar
log4j-core.jar
mini-j2ee.jar
mini-concurrent.jar
jass.jar
firebirdjmx.jar
firebirdsql-test.jar
in C:\calsoft\j2sdk\jre\lib\ext directory
My classpath is:-
C:\calsoft\j2sdk\lib\servlet.jar;C:\calsoft\j2sdk\jre\lib
Now i am trying to run my servlet i am getting an error
class java.lang.ClassNotFoundException class
java.lang.NullPointerException
I want to know wheather any chnages needed at apachi server side.
my code is
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.net.*;
import java.sql.*;
// create class inheritting from HttpServlet
public class firetest2 extends HttpServlet
{
PrintWriter pw;
Connection con;
String q;
String temp="good connection";
//------------------------init-------------------------------
public void init(ServletConfig config)throws ServletException
{
super.init(config);
try
{
Class.forName("org.firebirdsql.jdbc.FBDriver");
con = DriverManager.getConnection
("jdbc:firebirdsql:Archie.ncst.ernet.in/3050:c:\\users\\calypso\\datab
ase\\CALYPSODB.gdb","SYSDBA","masterkey");
} }
catch(ClassNotFoundException e)
{
temp=e.getClass().toString();
}
catch(SQLException e)
{
temp=e.getClass().toString();
}
}
//----------------------------doGet()---------------------------------
----------------
public void doGet(HttpServletRequest req,HttpServletResponse
res)
throws ServletException,IOException
{
res.setContentType("text/html");
pw=res.getWriter();
pw.println("<html>");
pw.println("<body>");
try
{
ResultSet rs;
pw.println(temp);
pw.println("inside doGet");
Statement stmt = con.createStatement
();
pw.println("after statement");
/* q ="select * from ROLEINFO;";
rs = stmt.executeQuery(q);
pw.println("outside loop");
if(rs.first())
{
pw.println("inside");
String key;
if(rs!=null)
{
do
{
key =rs.getString("ID");
pw.println("ID ="+key+" ");
key = rs.getString("NAME");
pw.print(" name = "+key+" ");
}while(rs.next());
}
}
else
{
pw.println("outside");
}
*/
}
catch(Exception e){
pw.println(e.getClass().toString());
}
pw.println("</body>");
pw.println("</html>");
}
//--------------------------------------------------------------------
----------------
}
please reply as soon as possible
sudarshan