Using Tomcat with MSAccess

2001-08-03 Thread Jeffrey Worst

I'm writing an applet using Tomcat to register new members for a library.
Everything works fine until I get to the part where the new information is
being inserted into the MSAccess DB.  I have commented below where the error
occurs.  Any help would be appreciated.

Thanks,

Jeff
--
//New member registration

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import java.sql.*;

public class NewMember extends HttpServlet {
   private Statement statement = null;
   private Connection connection = null;
   String url = jdbc:odbc:NewMember;
   String username=;
   String password=;

   public void init( ServletConfig config )
  throws ServletException
   {
  super.init( config );

  try {
 Class.forName( sun.jdbc.odbc.JdbcOdbcDriver );
 connection =
DriverManager.getConnection( url, username, password );
  }
  catch ( Exception e ) {
 e.printStackTrace();
 connection = null;
  }
   }

   public void doPost( HttpServletRequest req,
   HttpServletResponse res )
  throws ServletException, IOException
   {
  String passwd, member_type, fname, mname, lname, address1,
  address2, city, zip, country, home_phone, work_phone, email,
member_since, remarks;

  passwd= req.getParameter( passwd );
  member_type = req.getParameter( member_type );
  fname = req.getParameter( fname );
  mname = req.getParameter( mname );
  lname = req.getParameter( lname );
  address1 = req.getParameter( address1 );
  address2 = req.getParameter( address2 );
  city = req.getParameter( city );
  zip = req.getParameter( zip );
   country = req.getParameter( country );
  home_phone = req.getParameter( home_phone );
  work_phone = req.getParameter( work_phone );
  email = req.getParameter( email );
  member_since = req.getParameter( member_since );
  remarks = req.getParameter( remarks );

  PrintWriter output = res.getWriter();
  res.setContentType( text/html );

  if ( passwd.equals(  ) ||
   fname.equals(  ) ||
   lname.equals(  ) ) {
 output.println( H3 Please click the back  +
 button and fill in all  +
 fields./H3 );
 output.close();
 return;
  }

   //Below is where the problem occurs.  I get the HTML message below of An
error occured...
   //I think the insertIntoDB method is not working.  It's being inserted
into a MSAccess DB
   //which has been registered.

  boolean success = insertIntoDB(' + passwd + ',' + member_type +
',' + fname + ',' +
  mname + ',' + lname + ',' + address1 + ',' + address2 + ',' +
city + ',' + zip + ',' +
  country + ',' + home_phone + ',' + work_phone + ',' + email +
',' + member_since +
   ',' + remarks + ' );

  if ( success )
 output.print( H2Thank you  + fname +
for registering./H2 );
  else
 output.print( H2An error occurred.  +
   Please try again later./H2 );

  output.close();
   }

   private boolean insertIntoDB( String stringtoinsert )
   {
  try {
 statement = connection.createStatement();
 statement.execute(
INSERT INTO NewMember values ( +
stringtoinsert + ); );
 statement.close();
  }
  catch ( Exception e ) {
 System.err.println(
ERROR: Problems with adding new entry );
 e.printStackTrace();
 return false;
  }

  return true;
   }

   public void destroy()
   {
  try {
 connection.close();
  }
  catch( Exception e ) {
 System.err.println( Problem closing the database );
  }
   }
}




Re: Using Tomcat with MSAccess

2001-08-03 Thread Jeffrey Worst

I can't see any errors in the Tomcat DOS window so I'm assuming they have
scrolled off the screen.  The only error I see is the HTML generated by the
else clause if the insertIntoDB method doesn't run successfully.  I'm
running Win98 and the Access DB file access properties are only set to
Archive.

Jeff


- Original Message -
From: Bojan Smojver [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, August 03, 2001 10:23 PM
Subject: Re: Using Tomcat with MSAccess


 What's the actual error message?

 Maybe you can print out the SQL statement to see if the syntax is OK. It
 could be invalid SQL. Are you running this under Windows NT/2000 or
 9x/ME? Maybe the user Tomcat runs under doesn't have access rights on
 this database?

 I don't really use Access, I'm just trying to apply my PostgreSQL
 experiences...

 And maybe you can have a look at JBoss or similar EJB container. No more
 SQL...

 Bojan

 Jeffrey Worst wrote:
 
  I'm writing an applet using Tomcat to register new members for a
library.
  Everything works fine until I get to the part where the new information
is
  being inserted into the MSAccess DB.  I have commented below where the
error
  occurs.  Any help would be appreciated.
 
  Thanks,
 
  Jeff





Simple Tomcat Install on Win98

2001-07-25 Thread Jeffrey Worst



I'm having problems installing Tomcat on my Win98Se 
machine. Below are the directions from Jakarta for installing 
Tomcat. I've commented what I don't 
understand.Thanks,Jeff 
W.-How Do I Install the 
Binary Version of Tomcat?Very simple. You should:Download the 
zip/tar.gz/whatever file from http://jakarta.apache.org/downloads/binindex.html.Ive done this and everything went 
fine.Unpack the file into some directory (say foo). This 
should create a new subdirectory named "jakarta-tomcat-3.2.1". If it's not where 
you want it, move this directory to the desired location.///Did this 
and it went fine also./ Change directory to 
"jakarta-tomcat-3.2.1" and set a new environment variable (TOMCAT_HOME) to point 
to the root directory of your Tomcat hierarchy.This I dont 
understand. Are they talking about doing this in autoexec.bat or in the 
tomcat.bat file?On Win32 you should type: "set 
TOMCAT_HOME=foo\jakarta-tomcat-3.2.1" Again, are they talking 
about within autoexec.bat or someplace else?Set 
the environment variable JAVA_HOME to point to the root directory of your JDK 
hierarchy...Where is the environment variable JAVA HOME 
located? then add the Java interpreter to your PATH 
environment variable.How does one do 
this?


Simple (I think) Running Tomcat Question

2001-07-25 Thread Jeffrey Worst

I believe I now have Tomcat running successfully. But...

After starting Tomcat I get the following screen:
01-07-25 11:37:26 - ContextManager: Adding context Ctx(  )
01-07-25 11:37:26 - ContextManager: Adding context Ctx( /test )
01-07-25 11:37:29 - PoolTcpConnector: Starting HttpConnectionHandler on 8080
01-07-25 11:37:29 - PoolTcpConnector: Starting Ajp12ConnectionHandler on
8007


I then tried to run the Hello World applet.  When I successfully compile and
then try to run an applet, I get this error message:
Exception in thread main java.lang.NoSuchMethodError: main

Any ideas why?

Jeff W.


- Original Message -
From: Jim Cheesman [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, July 25, 2001 7:49 AM
Subject: Re: Simple Tomcat Install on Win98


 At 01:30 PM 25/07/01, you wrote:
 In html, which is horrible! Please sort it out!


 I'm having problems installing Tomcat on my Win98Se machine.  Below are
 the directions from Jakarta for installing Tomcat.  I've commented what I
 don't understand.
 

 snip/


 
 Change directory to jakarta-tomcat-3.2.1 and set a new environment
 variable (TOMCAT_HOME) to point to the root directory of your Tomcat
hierarchy.
 This I don t understand.  Are they talking about doing this in
 autoexec.bat or in the tomcat.bat file?

 In autoexec.bat


 
 On Win32 you should type:
 set TOMCAT_HOME=foo\jakarta-tomcat-3.2.1
 Again, are they talking about within autoexec.bat or someplace
else?

 In autoexec.bat


 
   Set the environment variable JAVA_HOME to point to the root directory
of
  your JDK hierarchy...
 Where is the environment variable JAVA HOME located?

 In autoexec.bat

 
  then add the Java interpreter to your PATH environment variable.
 How does one do this?

 In autoexec.bat (!)

 The basic syntax:
 set MY_ENVIRONMENT_VARIABLE=c:\path\to\whatever

 and to add to the previously set variable

 set MY_ENVIRONMENT_VARIABLE=%MY_ENVIRONMENT_VARIABLE%;c:\path\to\whatever





 
 


 --

*   Jim Cheesman   *
  Trabajo:
 [EMAIL PROTECTED] - (34)(91) 724 9200 x 2360
   I keep telling
 myself that I am a pathological
  liar, but I am not sure if
 I believe it.







Re: Simple (I think) Running Tomcat Question

2001-07-25 Thread Jeffrey Worst

Very true.  Let me go back and think this thing through some more so I can
post a more thoughtful question.

Thanks,

Jeff W.
- Original Message -
From: Matt Read [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, July 25, 2001 12:37 PM
Subject: Re: Simple (I think) Running Tomcat Question


 Hello World is a servlet, not an applet - a world of difference.

 Exactly how are you trying to run it?

 Matt.

 - Original Message -
 From: Jeffrey Worst [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: 25 July 2001 16:54
 Subject: Simple (I think) Running Tomcat Question


  I believe I now have Tomcat running successfully. But...
 
  After starting Tomcat I get the following screen:
  01-07-25 11:37:26 - ContextManager: Adding context Ctx(  )
  01-07-25 11:37:26 - ContextManager: Adding context Ctx( /test )
  01-07-25 11:37:29 - PoolTcpConnector: Starting HttpConnectionHandler on
 8080
  01-07-25 11:37:29 - PoolTcpConnector: Starting Ajp12ConnectionHandler on
  8007
 
 
  I then tried to run the Hello World applet.  When I successfully compile
 and
  then try to run an applet, I get this error message:
  Exception in thread main java.lang.NoSuchMethodError: main
 
  Any ideas why?
 
  Jeff W.
 
 
  - Original Message -
  From: Jim Cheesman [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Sent: Wednesday, July 25, 2001 7:49 AM
  Subject: Re: Simple Tomcat Install on Win98
 
 
   At 01:30 PM 25/07/01, you wrote:
   In html, which is horrible! Please sort it out!
  
  
   I'm having problems installing Tomcat on my Win98Se machine.  Below
are
   the directions from Jakarta for installing Tomcat.  I've commented
what
 I
   don't understand.
   
  
   snip/
  
  
   
   Change directory to jakarta-tomcat-3.2.1 and set a new environment
   variable (TOMCAT_HOME) to point to the root directory of your Tomcat
  hierarchy.
   This I don t understand.  Are they talking about doing this in
   autoexec.bat or in the tomcat.bat file?
  
   In autoexec.bat
  
  
   
   On Win32 you should type:
   set TOMCAT_HOME=foo\jakarta-tomcat-3.2.1
   Again, are they talking about within autoexec.bat or someplace
  else?
  
   In autoexec.bat
  
  
   
 Set the environment variable JAVA_HOME to point to the root
directory
  of
your JDK hierarchy...
   Where is the environment variable JAVA HOME located?
  
   In autoexec.bat
  
   
    then add the Java interpreter to your PATH environment variable.
   How does one do this?
  
   In autoexec.bat (!)
  
   The basic syntax:
   set MY_ENVIRONMENT_VARIABLE=c:\path\to\whatever
  
   and to add to the previously set variable
  
   set
 MY_ENVIRONMENT_VARIABLE=%MY_ENVIRONMENT_VARIABLE%;c:\path\to\whatever
  
  
  
  
  
   
   
  
  
   --
  
  *   Jim Cheesman   *
Trabajo:
   [EMAIL PROTECTED] - (34)(91) 724 9200 x 2360
 I keep telling
   myself that I am a pathological
liar, but I am not sure if
   I believe it.
  
  
  
 





File Not Found Error

2001-07-25 Thread Jeffrey Worst

I keep getting an HTTP 404 file not found error when I try to run a servlet.
My servlet class file is at C:\tomcat\Servlet\Ex197.class.  Hopefully the
html code below will show what I'm doing wrong:

Thanks,

Jeff

HTML
   HEAD
  TITLEEx 19.7/TITLE
   /HEAD

   BODY
  FORM METHOD=POST ACTION=
 http://localhost:8080/tomcat/Servlet/Ex197;
 What is your favorite pet?BRBR
 INPUT TYPE=radio NAME=animal VALUE=dogDogBR
 INPUT TYPE=radio NAME=animal VALUE=catCatBR
 INPUT TYPE=radio NAME=animal VALUE=birdBirdBR
 INPUT TYPE=radio NAME=animal VALUE=snakeSnakeBR
 INPUT TYPE=radio NAME=animal VALUE=none CHECKEDNone
 BRBRINPUT TYPE=submit VALUE=Submit
 INPUT TYPE=reset
  /FORM
   /BODY
/HTML