This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes JDBC connectivity problem through JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JDBC connectivity problem through JSP" Watch "JDBC connectivity problem through JSP" New topic
Author

JDBC connectivity problem through JSP

Sandeep Chhabra
Ranch Hand

Joined: Aug 28, 2005
Posts: 340
Hi,
I want to connect to an Access DB through JSP.



The above code works fine when called saperately from any applicatoin.
But when i call the method from a jsp page and put the above code file in WEB-INF\classes (use this as a bean), i get the following error :


Can anyone kindly help me regarding this problem.

Thanks


Regards<br />Sandy<br />[SCJP 5.0 - 75%]<br />[SCWCD 1.4 - 85%]<br />------------------<br />Tiger, Tiger burning bright,<br />Like a geek who works all night,<br />What new-fangled bit or byte,<br />Could ease the hacker's weary plight?
John Dunn
slicker
Ranch Hand

Joined: Jan 30, 2003
Posts: 1108
I usually make a jar file called, let's say, jdbcDriver.jar. This will contain the sun.jdbc.odbc.JdbcOdbcDriver directory's classes, etc. This can go into the WEB-INF/lib directory.

If you are really, really stuck; you could make a sample jar file, test.jar, with like one class and put it in the lib directory. Then from you jsp page access a class in that jar an d print the name. This way you KNOW you can hit the class, in a jar.


"No one appreciates the very special genius of your conversation as the dog does."
Abhinit Saxena
Greenhorn

Joined: Jan 10, 2006
Posts: 18
Try to do one more thing that.. Provide user name and password in DriverManager.getConnection.

I tried to use the similar code..and it is working fine in my bean as well as Standalone..Only difference is I am using Oracle Thin Driver and providing user name and password to it.
John Dunn
slicker
Ranch Hand

Joined: Jan 30, 2003
Posts: 1108
when I started with jdbc, (8 yrs ago or so...), I used the examples that came with the driver. Look in the directory of classes with you driver and I bet you find a to use.

get that to work in stand-alone, get that to work in a jar with stand-alone, then move jar to webserver by placing it in the lib directory.
Sandeep Chhabra
Ranch Hand

Joined: Aug 28, 2005
Posts: 340
Originally posted by Abhinit Saxena:
Try to do one more thing that.. Provide user name and password in DriverManager.getConnection.

I tried to use the similar code..and it is working fine in my bean as well as Standalone..Only difference is I am using Oracle Thin Driver and providing user name and password to it.


I tried this also but the result is same.
Sandeep Chhabra
Ranch Hand

Joined: Aug 28, 2005
Posts: 340
I want to create the jar file, but i am facing a small problem,
I cannot find the directory sun/jdbc/odbc/jdbcodbcdriver
could you please tell me where would i find this directory.

Thanks
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
Originally posted by Sandeep Chhabra:
Hi,
I want to connect to an Access DB through JSP.



The above code works fine when called saperately from any applicatoin.
But when i call the method from a jsp page and put the above code file in WEB-INF\classes (use this as a bean), i get the following error :


Can anyone kindly help me regarding this problem.

Thanks


By looking at error, I think, you haven't created DSN with name Web.

But it worked fine first time... Are you sure that you didn't pass username and password even first time...

Sandeep Chhabra
Ranch Hand

Joined: Aug 28, 2005
Posts: 340
Rathi ji,
The above mentioned code is working absolutely fine when i create a simple java application and call the getCategories function.

I never passed any username and pass, nor i have set any while creating the DSN.

Its just that when i call this method from a JSP page i get the error?

Had I not created the DSN properly, it would'nt have run even with the application.
Shrinivas Mujumdar
Ranch Hand

Joined: Aug 27, 2004
Posts: 328
Can you give me a JSP code which uses this class?

Add few SOPs to check whether it is giving a call to this class.

Shrinivas
Sandeep Chhabra
Ranch Hand

Joined: Aug 28, 2005
Posts: 340
Code for JSP

[ January 11, 2006: Message edited by: Sandeep Chhabra ]
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
You import attribute should be separated by comma ",". I noticed that you have three import attributes though.


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Abhinit Saxena
Greenhorn

Joined: Jan 10, 2006
Posts: 18
I tried to do it with access DB and found the same error..

I dont know whether it is MS-Access problem or not but try to go with system DSN in stead of user DSN (if u used one) and please let me know if the problem is got resolved..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDBC connectivity problem through JSP
 
Similar Threads
Oracle and Servlet JDBC Connection problems
reading data from jsp page to another jsp page using request.getParameter
confusion in running the program
confusion in running the program
Event in jButton