RE: DB2 and servlet ??? Help !!!

2002-08-01 Thread Turner, John


Is firstnme the name of your column?  Or should it be firstname?  If
that's an error, there should be a SQLException thrown, but I don't know the
behavior fo DB2...it may just be that you get null back.  In any case,
besides printing a stack trace, I would output something to the browser on a
SQLException just so you can see what's going on.

John Turner
[EMAIL PROTECTED]

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 01, 2002 1:47 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED];
[EMAIL PROTECTED]
Subject: DB2 and servlet ??? Help !!!


Hello everyone...

I am trying to connect the run a simple servlet to retrieve the
query results from DB2 database.

1. Before writing a servlet, I wrote a simple java file and was successful
in retrieving the
contents from DB2 UDB.

2. Then I just converted the same JAVA file into servlet by adding Servlet
API and syntax in it.
3. It compiles fine.
4. Then from a web page I try to pass one parameter to my servlet.
5. The servlet doesnot retrieve any records from the database which
initially it was bringing
when I wrote simple java file.

Code of my servlet is as:
--
import java.sql.*;
import java.lang.*;
import java.io.*;

public class Ndb2Tomcat{

   public static void main(String args[]) {


  try{
 Class.forName(COM.ibm.db2.jdbc.net.DB2Driver);
 }
 catch( ClassNotFoundException e2)
 {
  System.out.println(\nJDBC Driver class not found exception);
 }
 catch( Exception e)
 {
   System.out.println(\nDriver class not found exception);

}
try{
   Connection con = null;
  String url = jdbc:db2://100.3.13.34/SAMPLE;
   con = DriverManager.getConnection(url,db2admin, db2pwd);

// retrieve data from the database
   System.out.println(Retrieve some data from the database...);

   Statement stmt = con.createStatement();
   ResultSet rs = stmt.executeQuery(SELECT * from db2admin.employee
order by firstnme);

   System.out.println(Received results:);

   while (rs.next())
   {
  String a = rs.getString(1);
  String str = rs.getString(2);
  System.out.print( empno=  + a);
  System.out.print( firstname=  + str);
  System.out.print(\n);
   }
   rs.close();
  stmt.close();
   con.close();
 }
 catch (SQLException e1)
 {
  e1.printStackTrace();
 }

   }




Nishant Awasthi





--
To unsubscribe, e-mail:
mailto:[EMAIL PROTECTED]
For additional commands, e-mail:
mailto:[EMAIL PROTECTED]

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: DB2 and servlet ??? Help !!!

2002-08-01 Thread Nishant_Awasthi


Hello John

firstnme is the correct column name...
What bugs me is if you see my servlet code which I am again attaching...
I try to put try and ctach every where possible so that
I can at least printStackTrace() .
But to my surprise...I am not getting any exception...or stack trace...
instead I am getting simple HTML output ...
I am attaching what
1. I see in browser
2. servlet code

 BROWSER OUTPUT
---
paramater passed is 012


Count is0
Found the JDBC driver

Driver is properly loaded and registered
Connection URL is good
Retrieve some data from the database...
Received results:

Count is0
God Please help

--SERVLET CODE-
import java.sql.*;
import java.lang.*;
import java.io.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;


public class Ndb2Websphere extends HttpServlet {

  Statement stmt;
ResultSet rs;
   int count =0;

public void doGet (HttpServletRequest req, HttpServletResponse res)
 throws ServletException, IOException
{


  res.setContentType(text/html);

 ServletOutputStream out = res.getOutputStream();

 String emp = req.getParameter(empnumber);
 out.println(paramater passed is +emp + BR);
  out.println(BRBRCount is+ count);
 try{
  Class.forName(COM.ibm.db2.jdbc.net.DB2Driver);
   out.println(BRFound the JDBC driver BR);
 }
 catch( Exception e)
 {
  //e.printStackTrace();
out.println(\nDriver class not found
exception);
 }
 finally
  {
   out.println(BRDriver is properly loaded and
registered );
  }

   try{
Connection con = null;


   String url;

   out.println(BRConnection URL is  good);


try{
   con = DriverManager.getConnection
(jdbc:db2://10.3.13.34/SAMPLE,db2admin,db2pwd);
}
catch( Exception e4)
{
   e4.getMessage();
e4.printStackTrace();
}


  // retrieve data from the database

   out.println(BRRetrieve some data from the
database...);

try{
stmt = con.createStatement();
rs = stmt.executeQuery(SELECT empno from
db2admin.employee);
  }
 catch( Exception e5)
 {
   e5.getMessage();
e5.printStackTrace();
 }

   out.println(BRReceived results:);

 try{
 if(!rs.next())
   {
   count = count +1;
 String a = rs.getString(1);

   out.println( empno is  + a );
out.println(BRBRWhile Count is+ count);
   }
   }
   catch( Exception e6)
   {
   e6.printStackTrace();
   }
   out.println(BRBRCount is+ count);

   rs.close();
   stmt.close();
con.close();

}
catch (SQLException e1)
{
   e1.getMessage();
   e1.printStackTrace();
}
catch( Exception e)
{
   e.getMessage();
   e.printStackTrace();
}
finally
{
out.println(BRGod Please help);
}
  }
public void doPost (HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
doGet(req,res);
}


}


Nishant Awasthi






   

Turner,   

JohnTo: 'Tomcat Users List'   

JTurner@AAS.[EMAIL PROTECTED]  

com cc: (bcc: Nishant Awasthi)

 Subject: RE: DB2 and servlet ??? Help !!! 

08/01/2002

RE: DB2 and servlet ??? Help !!!

2002-08-01 Thread Wagoner, Mark

I think you are attempting to output the value if there is nothing in the
result set.

 if(!rs.next())

The .next() method will return true if it was able to fetch a row.  You are
saying, if there is no row then...

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 01, 2002 1:57 PM
To: Tomcat Users List
Subject: RE: DB2 and servlet ??? Help !!!



Hello John

firstnme is the correct column name...
What bugs me is if you see my servlet code which I am again attaching...
I try to put try and ctach every where possible so that
I can at least printStackTrace() .
But to my surprise...I am not getting any exception...or stack trace...
instead I am getting simple HTML output ...
I am attaching what
1. I see in browser
2. servlet code

 BROWSER OUTPUT
---
paramater passed is 012


Count is0
Found the JDBC driver

Driver is properly loaded and registered
Connection URL is good
Retrieve some data from the database...
Received results:

Count is0
God Please help

--SERVLET CODE-
import java.sql.*;
import java.lang.*;
import java.io.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;


public class Ndb2Websphere extends HttpServlet {

  Statement stmt;
ResultSet rs;
   int count =0;

public void doGet (HttpServletRequest req, HttpServletResponse res)
 throws ServletException, IOException
{


  res.setContentType(text/html);

 ServletOutputStream out = res.getOutputStream();

 String emp = req.getParameter(empnumber);
 out.println(paramater passed is +emp + BR);
  out.println(BRBRCount is+ count);
 try{
  Class.forName(COM.ibm.db2.jdbc.net.DB2Driver);
   out.println(BRFound the JDBC driver BR);
 }
 catch( Exception e)
 {
  //e.printStackTrace();
out.println(\nDriver class not found
exception);
 }
 finally
  {
   out.println(BRDriver is properly loaded and
registered );
  }

   try{
Connection con = null;


   String url;

   out.println(BRConnection URL is  good);


try{
   con = DriverManager.getConnection
(jdbc:db2://10.3.13.34/SAMPLE,db2admin,db2pwd);
}
catch( Exception e4)
{
   e4.getMessage();
e4.printStackTrace();
}


  // retrieve data from the database

   out.println(BRRetrieve some data from the
database...);

try{
stmt = con.createStatement();
rs = stmt.executeQuery(SELECT empno from
db2admin.employee);
  }
 catch( Exception e5)
 {
   e5.getMessage();
e5.printStackTrace();
 }

   out.println(BRReceived results:);

 try{
 if(!rs.next())
   {
   count = count +1;
 String a = rs.getString(1);

   out.println( empno is  + a );
out.println(BRBRWhile Count is+ count);
   }
   }
   catch( Exception e6)
   {
   e6.printStackTrace();
   }
   out.println(BRBRCount is+ count);

   rs.close();
   stmt.close();
con.close();

}
catch (SQLException e1)
{
   e1.getMessage();
   e1.printStackTrace();
}
catch( Exception e)
{
   e.getMessage();
   e.printStackTrace();
}
finally
{
out.println(BRGod Please help);
}
  }
public void doPost (HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
doGet(req,res);
}


}



Nishant Awasthi






 

Turner,

JohnTo: 'Tomcat Users List'

JTurner@AAS.[EMAIL PROTECTED]

com cc: (bcc: Nishant Awasthi

RE: DB2 and servlet ??? Help !!!

2002-08-01 Thread Turner, John


Nice catch!  You are right.  It should be

if(rs.next())

Or better yet...

while(rs.next())

John Turner
[EMAIL PROTECTED]

-Original Message-
From: Wagoner, Mark [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 01, 2002 2:02 PM
To: 'Tomcat Users List'
Subject: RE: DB2 and servlet ??? Help !!!


I think you are attempting to output the value if there is nothing in the
result set.

 if(!rs.next())

The .next() method will return true if it was able to fetch a row.  You are
saying, if there is no row then...

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 01, 2002 1:57 PM
To: Tomcat Users List
Subject: RE: DB2 and servlet ??? Help !!!



Hello John

firstnme is the correct column name...
What bugs me is if you see my servlet code which I am again attaching...
I try to put try and ctach every where possible so that
I can at least printStackTrace() .
But to my surprise...I am not getting any exception...or stack trace...
instead I am getting simple HTML output ...
I am attaching what
1. I see in browser
2. servlet code

 BROWSER OUTPUT
---
paramater passed is 012


Count is0
Found the JDBC driver

Driver is properly loaded and registered
Connection URL is good
Retrieve some data from the database...
Received results:

Count is0
God Please help

--SERVLET CODE-
import java.sql.*;
import java.lang.*;
import java.io.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;


public class Ndb2Websphere extends HttpServlet {

  Statement stmt;
ResultSet rs;
   int count =0;

public void doGet (HttpServletRequest req, HttpServletResponse res)
 throws ServletException, IOException
{


  res.setContentType(text/html);

 ServletOutputStream out = res.getOutputStream();

 String emp = req.getParameter(empnumber);
 out.println(paramater passed is +emp + BR);
  out.println(BRBRCount is+ count);
 try{
  Class.forName(COM.ibm.db2.jdbc.net.DB2Driver);
   out.println(BRFound the JDBC driver BR);
 }
 catch( Exception e)
 {
  //e.printStackTrace();
out.println(\nDriver class not found
exception);
 }
 finally
  {
   out.println(BRDriver is properly loaded and
registered );
  }

   try{
Connection con = null;


   String url;

   out.println(BRConnection URL is  good);


try{
   con = DriverManager.getConnection
(jdbc:db2://10.3.13.34/SAMPLE,db2admin,db2pwd);
}
catch( Exception e4)
{
   e4.getMessage();
e4.printStackTrace();
}


  // retrieve data from the database

   out.println(BRRetrieve some data from the
database...);

try{
stmt = con.createStatement();
rs = stmt.executeQuery(SELECT empno from
db2admin.employee);
  }
 catch( Exception e5)
 {
   e5.getMessage();
e5.printStackTrace();
 }

   out.println(BRReceived results:);

 try{
 if(!rs.next())
   {
   count = count +1;
 String a = rs.getString(1);

   out.println( empno is  + a );
out.println(BRBRWhile Count is+ count);
   }
   }
   catch( Exception e6)
   {
   e6.printStackTrace();
   }
   out.println(BRBRCount is+ count);

   rs.close();
   stmt.close();
con.close();

}
catch (SQLException e1)
{
   e1.getMessage();
   e1.printStackTrace();
}
catch( Exception e)
{
   e.getMessage();
   e.printStackTrace();
}
finally
{
out.println(BRGod Please help);
}
  }
public void doPost (HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
doGet(req,res

RE: DB2 and servlet ??? Help !!!

2002-08-01 Thread Nishant_Awasthi


Hello Mark,

Believe me there are rows in the table when I run the simple JAVA-DB2
file it retrieve
Received results:
 empno= 000150 firstname= BRUCE
 empno= 10 firstname= CHRISTINE
 empno= 000250 firstname= DANIEL
 empno= 000200 firstname= DAVID
 empno= 000130 firstname= DOLORES
 empno= 90 firstname= EILEEN
 empno= 000160 firstname= ELIZABETH
 empno= 000280 firstname= ETHEL
 empno= 70 firstname= EVA
 empno= 000140 firstname= HEATHER
 empno= 60 firstname= IRVING
 empno= 000190 firstname= JAMES
 empno= 000230 firstname= JAMES
 empno= 000340 firstname= JASON
 empno= 000220 firstname= JENNIFER
 empno= 50 firstname= JOHN
 empno= 000290 firstname= JOHN
 empno= 000270 firstname= MARIA
 empno= 000180 firstname= MARILYN
 empno= 000170 firstname= MASATOSHI
 empno= 000310 firstname= MAUDE
 empno= 20 firstname= MICHAEL
 empno= 000300 firstname= PHILIP
 empno= 000320 firstname= RAMLAL
 empno= 30 firstname= SALLY
 empno= 000240 firstname= SALVATORE
 empno= 000120 firstname= SEAN
 empno= 000260 firstname= SYBIL
 empno= 000100 firstname= THEODORE
 empno= 000110 firstname= VINCENZO
 empno= 000210 firstname= WILLIAM
 empno= 000330 firstname= WING

But When I write the same thing in a servlet it brings nothing...
Is there a problem with Connection URL or Connection String...
well I am using the same things in my simple java file

Thanks


Nishant Awasthi






   
   
Wagoner, Mark
   
MWagoner@wildflTo: 'Tomcat Users List'
   
avors.com  [EMAIL PROTECTED]   
   
cc: (bcc: Nishant Awasthi) 
   
08/01/2002 02:02Subject: RE: DB2 and servlet ??? Help 
!!! 
PM 
   
Please respond 
   
to Tomcat Users   
   
List  
   
   
   
   
   





I think you are attempting to output the value if there is nothing in the
result set.

 if(!rs.next())

The .next() method will return true if it was able to fetch a row.  You are
saying, if there is no row then...

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 01, 2002 1:57 PM
To: Tomcat Users List
Subject: RE: DB2 and servlet ??? Help !!!



Hello John

firstnme is the correct column name...
What bugs me is if you see my servlet code which I am again attaching...
I try to put try and ctach every where possible so that
I can at least printStackTrace() .
But to my surprise...I am not getting any exception...or stack trace...
instead I am getting simple HTML output ...
I am attaching what
1. I see in browser
2. servlet code

 BROWSER OUTPUT
---
paramater passed is 012


Count is0
Found the JDBC driver

Driver is properly loaded and registered
Connection URL is good
Retrieve some data from the database...
Received results:

Count is0
God Please help

--SERVLET CODE-
import java.sql.*;
import java.lang.*;
import java.io.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;


public class Ndb2Websphere extends HttpServlet {

  Statement stmt;
ResultSet rs;
   int count =0;

public void doGet (HttpServletRequest req, HttpServletResponse res)
 throws ServletException, IOException
{


  res.setContentType(text/html);

 ServletOutputStream out = res.getOutputStream();

 String emp = req.getParameter(empnumber);
 out.println(paramater passed is +emp + BR);
  out.println(BRBRCount is+ count);
 try{
  Class.forName(COM.ibm.db2.jdbc.net.DB2Driver);
   out.println(BRFound the JDBC driver BR);
 }
 catch( Exception e)
 {
  //e.printStackTrace();
out.println(\nDriver class not found
exception);
 }
 finally
  {
   out.println(BRDriver is properly loaded and
registered );
  }

   try{
Connection con = null;


   String url

RE: DB2 and servlet ??? Help !!!

2002-08-01 Thread Nishant_Awasthi


I tried both ways
while(rs.next())
and
if(!rs.next())
both gives the same web browser output



Nishant Awasthi
Corporate Systems Development
Progressive Insurance







   

Turner,   

JohnTo: 'Tomcat Users List'   

JTurner@AAS.[EMAIL PROTECTED]  

com cc: (bcc: Nishant Awasthi)

 Subject: RE: DB2 and servlet ??? Help !!! 

08/01/2002 

02:07 PM   

Please 

respond to 

Tomcat Users  

List  

   

   







Nice catch!  You are right.  It should be

if(rs.next())

Or better yet...

while(rs.next())

John Turner
[EMAIL PROTECTED]

-Original Message-
From: Wagoner, Mark [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 01, 2002 2:02 PM
To: 'Tomcat Users List'
Subject: RE: DB2 and servlet ??? Help !!!


I think you are attempting to output the value if there is nothing in the
result set.

 if(!rs.next())

The .next() method will return true if it was able to fetch a row.  You are
saying, if there is no row then...

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 01, 2002 1:57 PM
To: Tomcat Users List
Subject: RE: DB2 and servlet ??? Help !!!



Hello John

firstnme is the correct column name...
What bugs me is if you see my servlet code which I am again attaching...
I try to put try and ctach every where possible so that
I can at least printStackTrace() .
But to my surprise...I am not getting any exception...or stack trace...
instead I am getting simple HTML output ...
I am attaching what
1. I see in browser
2. servlet code

 BROWSER OUTPUT
---
paramater passed is 012


Count is0
Found the JDBC driver

Driver is properly loaded and registered
Connection URL is good
Retrieve some data from the database...
Received results:

Count is0
God Please help

--SERVLET CODE-
import java.sql.*;
import java.lang.*;
import java.io.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;


public class Ndb2Websphere extends HttpServlet {

  Statement stmt;
ResultSet rs;
   int count =0;

public void doGet (HttpServletRequest req, HttpServletResponse res)
 throws ServletException, IOException
{


  res.setContentType(text/html);

 ServletOutputStream out = res.getOutputStream();

 String emp = req.getParameter(empnumber);
 out.println(paramater passed is +emp + BR);
  out.println(BRBRCount is+ count);
 try{
  Class.forName(COM.ibm.db2.jdbc.net.DB2Driver);
   out.println(BRFound the JDBC driver BR);
 }
 catch( Exception e)
 {
  //e.printStackTrace();
out.println(\nDriver class not found
exception);
 }
 finally
  {
   out.println(BRDriver is properly loaded and
registered );
  }

   try{
Connection con = null;


   String url;

   out.println(BRConnection URL is  good);


try{
   con = DriverManager.getConnection
(jdbc:db2://10.3.13.34/SAMPLE,db2admin,db2pwd);
}
catch( Exception e4)
{
   e4.getMessage();
e4.printStackTrace();
}


  // retrieve data from the database

   out.println(BRRetrieve some data from the
database...);

try{
stmt = con.createStatement();
rs = stmt.executeQuery(SELECT empno from
db2admin.employee);
  }
 catch( Exception e5

Re: DB2 and servlet ??? Help !!!

2002-08-01 Thread Michael Locasto

Hi,

Assuming this is the SQL you want to submit:


 try{
 stmt = con.createStatement();
 rs = stmt.executeQuery(SELECT empno
from
 db2admin.employee);

shouldn't it be

if( rs.next() ){

do{
  count++;
  out.println(  empno is +rs.getString( 1 ) );

}while( rs.next() );

}

or something along those lines? (rather than the !rs.next() )


  try{
  if(!rs.next())
{
count = count +1;
  String a = rs.getString(1);

out.println( empno is  + a );
 out.println(BRBRWhile Count is+ count);
}




--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: DB2 and servlet ??? Help !!!

2002-08-01 Thread Michael Locasto

Hi,

Your parameter is '012', while it appears that the employeenumbers in your
database are more like:

empno= 000150


quote
 BROWSER OUTPUT
---
paramater passed is 012

Count is0
Found the JDBC driver

Driver is properly loaded and registered
Connection URL is good
Retrieve some data from the database...
Received results:

Count is0
God Please help

/quote


Regards,
Michael



- Original Message -
From: [EMAIL PROTECTED]
To: Tomcat Users List [EMAIL PROTECTED]
Sent: Thursday, August 01, 2002 2:10 PM
Subject: RE: DB2 and servlet ??? Help !!!



 I tried both ways
 while(rs.next())
 and
 if(!rs.next())
 both gives the same web browser output
 
 


 Nishant Awasthi
 Corporate Systems Development
 Progressive Insurance








 Turner,
 JohnTo: 'Tomcat Users List'
 JTurner@AAS.
[EMAIL PROTECTED]
 com cc: (bcc: Nishant Awasthi)
  Subject: RE: DB2 and
servlet ??? Help !!!
 08/01/2002
 02:07 PM
 Please
 respond to
 Tomcat Users
 List








 Nice catch!  You are right.  It should be

 if(rs.next())

 Or better yet...

 while(rs.next())

 John Turner
 [EMAIL PROTECTED]

 -Original Message-
 From: Wagoner, Mark [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, August 01, 2002 2:02 PM
 To: 'Tomcat Users List'
 Subject: RE: DB2 and servlet ??? Help !!!


 I think you are attempting to output the value if there is nothing in
the
 result set.

  if(!rs.next())

 The .next() method will return true if it was able to fetch a row.  You
are
 saying, if there is no row then...

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, August 01, 2002 1:57 PM
 To: Tomcat Users List
 Subject: RE: DB2 and servlet ??? Help !!!



 Hello John

 firstnme is the correct column name...
 What bugs me is if you see my servlet code which I am again attaching...
 I try to put try and ctach every where possible so that
 I can at least printStackTrace() .
 But to my surprise...I am not getting any exception...or stack trace...
 instead I am getting simple HTML output ...
 I am attaching what
 1. I see in browser
 2. servlet code

  BROWSER OUTPUT
 ---
 paramater passed is 012


 Count is0
 Found the JDBC driver

 Driver is properly loaded and registered
 Connection URL is good
 Retrieve some data from the database...
 Received results:

 Count is0
 God Please help

 --SERVLET CODE-
 import java.sql.*;
 import java.lang.*;
 import java.io.*;
 import java.io.*;
 import javax.servlet.*;
 import javax.servlet.http.*;


 public class Ndb2Websphere extends HttpServlet {

   Statement stmt;
 ResultSet rs;
int count =0;

 public void doGet (HttpServletRequest req, HttpServletResponse res)
  throws ServletException, IOException
 {


   res.setContentType(text/html);

  ServletOutputStream out = res.getOutputStream();

  String emp = req.getParameter(empnumber);
  out.println(paramater passed is +emp + BR);
   out.println(BRBRCount is+ count);
  try{
   Class.forName(COM.ibm.db2.jdbc.net.DB2Driver);
out.println(BRFound the JDBC driver BR);
  }
  catch( Exception e)
  {
   //e.printStackTrace();
 out.println(\nDriver class not found
 exception);
  }
  finally
   {
out.println(BRDriver is properly loaded
and
 registered );
   }

try{
 Connection con = null;


String url;

out.println(BRConnection URL is  good);


 try{
con = DriverManager.getConnection
 (jdbc:db2://10.3.13.34/SAMPLE,db2admin,db2pwd);
 }
 catch( Exception e4)
 {
e4.getMessage();
 e4.printStackTrace();
 }


   // retrieve data from the database

out.println(BRRetrieve some data from the
 database...);

 try{
 stmt = con.createStatement();
 rs = stmt.executeQuery(SELECT empno
from
 db2admin.employee);
   }
  catch( Exception e5)
  {
e5.getMessage();
 e5

RE: DB2 and servlet ??? Help !!!

2002-08-01 Thread Durham David Cntr 805CSS/SCBE

brings nothing??  There is no SQLException, or nullpointer or something like that??  

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, August 01, 2002 1:08 PM
 To: Tomcat Users List
 Subject: RE: DB2 and servlet ??? Help !!!
 
 
 
 Hello Mark,
 
 Believe me there are rows in the table when I run the simple JAVA-DB2
 file it retrieve
 Received results:
  empno= 000150 firstname= BRUCE
  empno= 10 firstname= CHRISTINE
  empno= 000250 firstname= DANIEL
  empno= 000200 firstname= DAVID
  empno= 000130 firstname= DOLORES
  empno= 90 firstname= EILEEN
  empno= 000160 firstname= ELIZABETH
  empno= 000280 firstname= ETHEL
  empno= 70 firstname= EVA
  empno= 000140 firstname= HEATHER
  empno= 60 firstname= IRVING
  empno= 000190 firstname= JAMES
  empno= 000230 firstname= JAMES
  empno= 000340 firstname= JASON
  empno= 000220 firstname= JENNIFER
  empno= 50 firstname= JOHN
  empno= 000290 firstname= JOHN
  empno= 000270 firstname= MARIA
  empno= 000180 firstname= MARILYN
  empno= 000170 firstname= MASATOSHI
  empno= 000310 firstname= MAUDE
  empno= 20 firstname= MICHAEL
  empno= 000300 firstname= PHILIP
  empno= 000320 firstname= RAMLAL
  empno= 30 firstname= SALLY
  empno= 000240 firstname= SALVATORE
  empno= 000120 firstname= SEAN
  empno= 000260 firstname= SYBIL
  empno= 000100 firstname= THEODORE
  empno= 000110 firstname= VINCENZO
  empno= 000210 firstname= WILLIAM
  empno= 000330 firstname= WING
 
 But When I write the same thing in a servlet it brings nothing...
 Is there a problem with Connection URL or Connection String...
 well I am using the same things in my simple java file
 
 Thanks
 --
 --
 
 Nishant Awasthi
 
 
 
 
 
 
   
 
 Wagoner, Mark   
 
 MWagoner@wildflTo: 'Tomcat 
 Users List'   
 avors.com  
 [EMAIL PROTECTED]  
 cc: (bcc: 
 Nishant Awasthi)
 08/01/2002 02:02Subject: RE: 
 DB2 and servlet ??? Help !!! 
 PM
 
 Please respond
 
 to Tomcat Users  
 
 List 
 
   
 
   
 
 
 
 
 
 
 I think you are attempting to output the value if there is 
 nothing in the
 result set.
 
  if(!rs.next())
 
 The .next() method will return true if it was able to fetch a 
 row.  You are
 saying, if there is no row then...
 
 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, August 01, 2002 1:57 PM
 To: Tomcat Users List
 Subject: RE: DB2 and servlet ??? Help !!!
 
 
 
 Hello John
 
 firstnme is the correct column name...
 What bugs me is if you see my servlet code which I am again 
 attaching...
 I try to put try and ctach every where possible so that
 I can at least printStackTrace() .
 But to my surprise...I am not getting any exception...or 
 stack trace...
 instead I am getting simple HTML output ...
 I am attaching what
 1. I see in browser
 2. servlet code
 
  BROWSER OUTPUT
 ---
 paramater passed is 012
 
 
 Count is0
 Found the JDBC driver
 
 Driver is properly loaded and registered
 Connection URL is good
 Retrieve some data from the database...
 Received results:
 
 Count is0
 God Please help
 
 --SERVLET CODE-
 import java.sql.*;
 import java.lang.*;
 import java.io.*;
 import java.io.*;
 import javax.servlet.*;
 import javax.servlet.http.*;
 
 
 public class Ndb2Websphere extends HttpServlet {
 
   Statement stmt;
 ResultSet rs;
int count =0;
 
 public void doGet (HttpServletRequest req, 
 HttpServletResponse res)
  throws ServletException, IOException
 {
 
 
   res.setContentType(text/html);
 
  ServletOutputStream out = res.getOutputStream();
 
  String emp = req.getParameter(empnumber);
  out.println(paramater passed is +emp + BR);
   out.println(BRBRCount is+ count);
  try{
   Class.forName(COM.ibm.db2.jdbc.net.DB2Driver);
out.println(BRFound the JDBC driver BR);
  }
  catch( Exception e

Re: DB2 and servlet ??? Help !!!

2002-08-01 Thread Michael Locasto

...and I'm an idiot, because the SQL statement doesn't filter by them, so
it's quite inconsequential, really. :)

rs = stmt.executeQuery(SELECT empno from db2admin.employee);

Michael


- Original Message -
From: Michael Locasto [EMAIL PROTECTED]
To: Tomcat Users List [EMAIL PROTECTED]
Sent: Thursday, August 01, 2002 2:16 PM
Subject: Re: DB2 and servlet ??? Help !!!


 Hi,

 Your parameter is '012', while it appears that the employeenumbers in
your
 database are more like:

 empno= 000150


 quote
  BROWSER OUTPUT
 ---
 paramater passed is 012

 Count is0
 Found the JDBC driver

 Driver is properly loaded and registered
 Connection URL is good
 Retrieve some data from the database...
 Received results:

 Count is0
 God Please help

 /quote


 Regards,
 Michael



 - Original Message -
 From: [EMAIL PROTECTED]
 To: Tomcat Users List [EMAIL PROTECTED]
 Sent: Thursday, August 01, 2002 2:10 PM
 Subject: RE: DB2 and servlet ??? Help !!!


 
  I tried both ways
  while(rs.next())
  and
  if(!rs.next())
  both gives the same web browser output
  

 
 
 
  Nishant Awasthi
  Corporate Systems Development
  Progressive Insurance
 
 
 
 
 
 
 
 
  Turner,
  JohnTo: 'Tomcat Users List'
  JTurner@AAS.
 [EMAIL PROTECTED]
  com cc: (bcc: Nishant
Awasthi)
   Subject: RE: DB2 and
 servlet ??? Help !!!
  08/01/2002
  02:07 PM
  Please
  respond to
  Tomcat Users
  List
 
 
 
 
 
 
 
 
  Nice catch!  You are right.  It should be
 
  if(rs.next())
 
  Or better yet...
 
  while(rs.next())
 
  John Turner
  [EMAIL PROTECTED]
 
  -Original Message-
  From: Wagoner, Mark [mailto:[EMAIL PROTECTED]]
  Sent: Thursday, August 01, 2002 2:02 PM
  To: 'Tomcat Users List'
  Subject: RE: DB2 and servlet ??? Help !!!
 
 
  I think you are attempting to output the value if there is nothing in
 the
  result set.
 
   if(!rs.next())
 
  The .next() method will return true if it was able to fetch a row.
You
 are
  saying, if there is no row then...
 
  -Original Message-
  From: [EMAIL PROTECTED]
  [mailto:[EMAIL PROTECTED]]
  Sent: Thursday, August 01, 2002 1:57 PM
  To: Tomcat Users List
  Subject: RE: DB2 and servlet ??? Help !!!
 
 
 
  Hello John
 
  firstnme is the correct column name...
  What bugs me is if you see my servlet code which I am again
attaching...
  I try to put try and ctach every where possible so that
  I can at least printStackTrace() .
  But to my surprise...I am not getting any exception...or stack
trace...
  instead I am getting simple HTML output ...
  I am attaching what
  1. I see in browser
  2. servlet code
 
   BROWSER OUTPUT
  ---
  paramater passed is 012
 
 
  Count is0
  Found the JDBC driver
 
  Driver is properly loaded and registered
  Connection URL is good
  Retrieve some data from the database...
  Received results:
 
  Count is0
  God Please help
 
  --SERVLET CODE-
  import java.sql.*;
  import java.lang.*;
  import java.io.*;
  import java.io.*;
  import javax.servlet.*;
  import javax.servlet.http.*;
 
 
  public class Ndb2Websphere extends HttpServlet {
 
Statement stmt;
  ResultSet rs;
 int count =0;
 
  public void doGet (HttpServletRequest req, HttpServletResponse
res)
   throws ServletException, IOException
  {
 
 
res.setContentType(text/html);
 
   ServletOutputStream out = res.getOutputStream();
 
   String emp = req.getParameter(empnumber);
   out.println(paramater passed is +emp + BR);
out.println(BRBRCount is+ count);
   try{
Class.forName(COM.ibm.db2.jdbc.net.DB2Driver);
 out.println(BRFound the JDBC driver BR);
   }
   catch( Exception e)
   {
//e.printStackTrace();
  out.println(\nDriver class not found
  exception);
   }
   finally
{
 out.println(BRDriver is properly loaded
 and
  registered );
}
 
 try{
  Connection con = null;
 
 
 String url;
 
 out.println(BRConnection URL is  good);
 
 
  try{
 con = DriverManager.getConnection
  (jdbc:db2://10.3.13.34/SAMPLE,db2admin,db2pwd);
  }
  catch( Exception e4

Re: DB2 and servlet ??? Help !!!

2002-08-01 Thread Nishant_Awasthi


Please don't look at the parameters
As I am not using parameter in my query...
Right now I am just trying to run a very simple query...
Parameter has been output just for testing if servlet is taking wirte
parameter vvalues or not...

Parameters are not being used anywhere in the whole servlet  code..
Thanks


Nishant Awasthi
Corporate Systems Development
Progressive Insurance







   
  
Michael   
  
Locasto   To: Tomcat Users List 
  
[EMAIL PROTECTED][EMAIL PROTECTED]
  
umbia.edu cc: (bcc: Nishant Awasthi)  
  
   Subject: Re: DB2 and servlet ??? Help 
!!! 
08/01/2002 
  
02:16 PM   
  
Please respond 
  
to Tomcat 
  
Users List
  
   
  
   
  





Hi,

Your parameter is '012', while it appears that the employeenumbers in your
database are more like:

empno= 000150


quote
 BROWSER OUTPUT
---
paramater passed is 012

Count is0
Found the JDBC driver

Driver is properly loaded and registered
Connection URL is good
Retrieve some data from the database...
Received results:

Count is0
God Please help

/quote


Regards,
Michael



- Original Message -
From: [EMAIL PROTECTED]
To: Tomcat Users List [EMAIL PROTECTED]
Sent: Thursday, August 01, 2002 2:10 PM
Subject: RE: DB2 and servlet ??? Help !!!



 I tried both ways
 while(rs.next())
 and
 if(!rs.next())
 both gives the same web browser output
 
 


 Nishant Awasthi
 Corporate Systems Development
 Progressive Insurance








 Turner,
 JohnTo: 'Tomcat Users List'
 JTurner@AAS.
[EMAIL PROTECTED]
 com cc: (bcc: Nishant Awasthi)
  Subject: RE: DB2 and
servlet ??? Help !!!
 08/01/2002
 02:07 PM
 Please
 respond to
 Tomcat Users
 List








 Nice catch!  You are right.  It should be

 if(rs.next())

 Or better yet...

 while(rs.next())

 John Turner
 [EMAIL PROTECTED]

 -Original Message-
 From: Wagoner, Mark [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, August 01, 2002 2:02 PM
 To: 'Tomcat Users List'
 Subject: RE: DB2 and servlet ??? Help !!!


 I think you are attempting to output the value if there is nothing in
the
 result set.

  if(!rs.next())

 The .next() method will return true if it was able to fetch a row.  You
are
 saying, if there is no row then...

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, August 01, 2002 1:57 PM
 To: Tomcat Users List
 Subject: RE: DB2 and servlet ??? Help !!!



 Hello John

 firstnme is the correct column name...
 What bugs me is if you see my servlet code which I am again attaching...
 I try to put try and ctach every where possible so that
 I can at least printStackTrace() .
 But to my surprise...I am not getting any exception...or stack trace...
 instead I am getting simple HTML output ...
 I am attaching what
 1. I see in browser
 2. servlet code

  BROWSER OUTPUT
 ---
 paramater passed is 012


 Count is0
 Found the JDBC driver

 Driver is properly loaded and registered
 Connection URL is good
 Retrieve some data from the database...
 Received results:

 Count is0
 God Please help

 --SERVLET CODE-
 import java.sql.*;
 import java.lang.*;
 import java.io.*;
 import java.io.*;
 import javax.servlet.*;
 import javax.servlet.http.*;


 public class Ndb2Websphere extends HttpServlet {

   Statement stmt;
 ResultSet rs;
int count =0;

 public void doGet (HttpServletRequest req, HttpServletResponse res)
  throws ServletException, IOException
 {


   res.setContentType(text/html);

  ServletOutputStream out = res.getOutputStream

Re: DB2 and servlet ??? Help !!!

2002-08-01 Thread Nishant_Awasthi


Hello
I think I found where the problem is
When I try to print e4.getmessage() while opening my conenction as given
below:
   try{
  con = DriverManager.getConnection
(jdbc:db2://10.3.13.34/SAMPLE,db2admin,db2pwd);
}
catch( Exception e4)
{
   out.println( connection +e4.getMessage
());
e4.printStackTrace();
}

I got something different in the web browser output:
It now says
WEB BROWSER OUTPUT -
[paramater passed is 10


Count is0
Found the JDBC driver

Driver is properly loaded and registered connection [IBM][JDBC Driver]
CLI0621E Unsupported JDBC Server configuration.
Connection URL is good
Retrieve some data from the database... stmt and rs null
Received results:

Count is0
God Please help


Now at least I know that there is some problem with JDBC Driver...
But I don't know why this is hapenning though while compiling  simple java
file it
never gave this error...



Nishant Awasthi
Corporate Systems Development
Progressive Insurance







   

Nishant_Awasthi@progr  

essive.com   To: Tomcat Users List   

 [EMAIL PROTECTED]  

08/01/2002 02:25 PM  cc: (bcc: Nishant Awasthi)

Please respond toSubject: Re: DB2 and servlet ??? 
Help !!! 
Tomcat Users List

   

   







Please don't look at the parameters
As I am not using parameter in my query...
Right now I am just trying to run a very simple query...
Parameter has been output just for testing if servlet is taking wirte
parameter vvalues or not...

Parameters are not being used anywhere in the whole servlet  code..
Thanks



Nishant Awasthi
Corporate Systems Development
Progressive Insurance








Michael
Locasto   To: Tomcat Users List
[EMAIL PROTECTED][EMAIL PROTECTED]
umbia.edu cc: (bcc: Nishant Awasthi)
   Subject: Re: DB2 and servlet
??? Help !!!
08/01/2002
02:16 PM
Please respond
to Tomcat
Users List







Hi,

Your parameter is '012', while it appears that the employeenumbers in your
database are more like:

empno= 000150


quote
 BROWSER OUTPUT
---
paramater passed is 012

Count is0
Found the JDBC driver

Driver is properly loaded and registered
Connection URL is good
Retrieve some data from the database...
Received results:

Count is0
God Please help

/quote


Regards,
Michael



- Original Message -
From: [EMAIL PROTECTED]
To: Tomcat Users List [EMAIL PROTECTED]
Sent: Thursday, August 01, 2002 2:10 PM
Subject: RE: DB2 and servlet ??? Help !!!



 I tried both ways
 while(rs.next())
 and
 if(!rs.next())
 both gives the same web browser output
 
 


 Nishant Awasthi
 Corporate Systems Development
 Progressive Insurance








 Turner,
 JohnTo: 'Tomcat Users List'
 JTurner@AAS.
[EMAIL PROTECTED]
 com cc: (bcc: Nishant Awasthi)
  Subject: RE: DB2 and
servlet ??? Help !!!
 08/01/2002
 02:07 PM
 Please
 respond to
 Tomcat Users
 List








 Nice catch!  You are right.  It should be

 if(rs.next())

 Or better yet...

 while(rs.next())

 John Turner
 [EMAIL PROTECTED]

 -Original Message-
 From: Wagoner, Mark [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, August 01, 2002 2:02 PM
 To: 'Tomcat Users List'
 Subject: RE: DB2 and servlet ??? Help !!!


 I think you are attempting to output the value if there is nothing in
the
 result set.

  if(!rs.next())

 The .next() method will return true if it was able to fetch a row.  You
are
 saying, if there is no row

DB2 and servlet ??? Help !!!

2002-08-01 Thread Nishant_Awasthi

Hello everyone...

I am trying to connect the run a simple servlet to retrieve the
query results from DB2 database.

1. Before writing a servlet, I wrote a simple java file and was successful
in retrieving the
contents from DB2 UDB.

2. Then I just converted the same JAVA file into servlet by adding Servlet
API and syntax in it.
3. It compiles fine.
4. Then from a web page I try to pass one parameter to my servlet.
5. The servlet doesnot retrieve any records from the database which
initially it was bringing
when I wrote simple java file.

Code of my servlet is as:
--
import java.sql.*;
import java.lang.*;
import java.io.*;

public class Ndb2Tomcat{

   public static void main(String args[]) {


  try{
 Class.forName(COM.ibm.db2.jdbc.net.DB2Driver);
 }
 catch( ClassNotFoundException e2)
 {
  System.out.println(\nJDBC Driver class not found exception);
 }
 catch( Exception e)
 {
   System.out.println(\nDriver class not found exception);

}
try{
   Connection con = null;
  String url = jdbc:db2://100.3.13.34/SAMPLE;
   con = DriverManager.getConnection(url,db2admin, db2pwd);

// retrieve data from the database
   System.out.println(Retrieve some data from the database...);

   Statement stmt = con.createStatement();
   ResultSet rs = stmt.executeQuery(SELECT * from db2admin.employee
order by firstnme);

   System.out.println(Received results:);

   while (rs.next())
   {
  String a = rs.getString(1);
  String str = rs.getString(2);
  System.out.print( empno=  + a);
  System.out.print( firstname=  + str);
  System.out.print(\n);
   }
   rs.close();
  stmt.close();
   con.close();
 }
 catch (SQLException e1)
 {
  e1.printStackTrace();
 }

   }



Nishant Awasthi





--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]