Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC connectivity problem through JSP

 
Sandeep Chhabra
Ranch Hand
Posts: 340
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
John Dunn
slicker
Ranch Hand
Posts: 1108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Abhinit Saxena
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 340
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 340
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 340
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 340
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Code for JSP

[ January 11, 2006: Message edited by: Sandeep Chhabra ]
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You import attribute should be separated by comma ",". I noticed that you have three import attributes though.
 
Abhinit Saxena
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic