wood burning stoves 2.0*
The moose likes Servlets and the fly likes Servlets and SQL Express 2005 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlets and SQL Express 2005 " Watch "Servlets and SQL Express 2005 " New topic
Author

Servlets and SQL Express 2005

Rahul Sudip Bose
Ranch Hand

Joined: Jan 21, 2011
Posts: 637

NEW to servlets and database. I made a database "my-users", in sql express 2005. It has a table "user-info", with columns : user and password. I want my servlet to access that table and print all the user names and passwords. I am trying to deploy this servlet in apache tomcat 5.5 on windows 7 64-bit os.

I can make it work in sql2000, but not in express 2005. Here is my code, how do i make it work ?



SCJP 6. Learning more now.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

What is the exception?


// where is the dsn ?

You are using a type 4 driver, you don't need a DNS.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Rahul Sudip Bose
Ranch Hand

Joined: Jan 21, 2011
Posts: 637

Paul Sturrock wrote:What is the exception?


// where is the dsn ?

You are using a type 4 driver, you don't need a DNS.


I got this driver from the net. How does one choose a driver ? Is there a type 1 driver for this ? The servlet was compiled successfully. Here is the exception in tomcat 5.5 :



How do i find the stack trace inside the logs folder as mentioned above "note The full stack trace of the root cause is available in the Apache Tomcat/5.5.31 logs. "?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


I got this driver from the net. How does one choose a driver ? Is there a type 1 driver for this ?

Why do you want to use a type 1 driver?


javax.servlet.ServletException: Class Connect is not a Servlet

The error message says it all really. Your are trying to service an HTTP request with a class that is not a Servlet.
Rahul Sudip Bose
Ranch Hand

Joined: Jan 21, 2011
Posts: 637

Paul Sturrock wrote:
javax.servlet.ServletException: Class Connect is not a Servlet
The error message says it all really. Your are trying to service an HTTP request with a class that is not a Servlet.


Sorry, it should have struck me in the 1st line of code itself. This servlet was supposed to be "called" by another. I revised the code as follows and got an error in tomcat when i try to run it by manually entering this in the browser : "http://localhost:8080/quiz/sql2005" where sql2005 is the url-pattern.

Here is the revised code :


here is the error in tomcat :
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Your Servlet is written to support POST requests only. If the request is a GET, you will need to implement doGet too.
Rahul Sudip Bose
Ranch Hand

Joined: Jan 21, 2011
Posts: 637

Paul Sturrock wrote:
I got this driver from the net. How does one choose a driver ? Is there a type 1 driver for this ?
Why do you want to use a type 1 driver?


A person i had asked for help told me that generally type 1 drivers are used. 2,3,4 are rarely used. Is this correct ? I am a beginner in servlets so i am not very confident now, so can you recommend any book,website etc which will be helpful. I already have kathy sierra's book which i am hardly using. most of my servlet knowledge is from the internet.

regards.
Rahul Sudip Bose
Ranch Hand

Joined: Jan 21, 2011
Posts: 637

Paul Sturrock wrote:Your Servlet is written to support POST requests only. If the request is a GET, you will need to implement doGet too.


how do i do that ? I want to make my servlet access the table in database and print all the user names and passwords on the screen.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

No, very wrong. A type 1 driver is the JDBC-ODBC bridge which is not for production software (as Oracle state). Type 4 is (in my experience) by far the most widely used, probably because it is the only one that can run without any specific changes or configuration made to the environment it is run in.

I can't recommend a book - it is years since I read a Servlet book. The Servlet specification is a good thing to read (essential, if you are going to be using Servlets long term). A simpler entry point is the JEE tutorial.
Rahul Sudip Bose
Ranch Hand

Joined: Jan 21, 2011
Posts: 637

Paul Sturrock wrote:No, very wrong. A type 1 driver is the JDBC-ODBC bridge which is not for production software (as Oracle state). Type 4 is (in my experience) by far the most widely used, probably because it is the only one that can run without any specific changes or configuration made to the environment it is run in.

I can't recommend a book - it is years since I read a Servlet book. The Servlet specification is a good thing to read (essential, if you are going to be using Servlets long term). A simpler entry point is the JEE tutorial.


can you suggest corrections to my program so that it works properly ?

thanks for hearing patiently.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

With Servlets you need to implement a method for each HTTP method you intended to support. If you are not sure what an HTTP method is I'd stop trying to write code for an few moments and go read up on them. (see the link I supplied). Your Servlet (as written) supports POST, but you are using GET. Have a read of the JavaDocs for the class HttpServlet your Servlet is extending.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Servlets and SQL Express 2005