• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jstl:sql no suitable driver error

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
OS WIN 2K, Tomcat is 4.1.3 , jdk 1.4.2_03 , udb is 7.2
When I use the following code in a jsp it works without a problem

Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
con = DriverManager.getConnection( ); // proper arguments inside

But, If I replace the above with the following in the same file , I get
the exception

javax.servlet.ServletException: Unable to get connection, DataSource
invalid: "No suitable driver"

<sql:setDataSource var="myDataSource" driver="COM.ibm.db2.jdbc.app.DB2Driver" url="jdbc :db2:mydb" user="abc" password="xyz" />
<sql:query var="rowdetails" dataSource=${myDataSource}>
SELECT a, b, c from sometable
</sql:query>



I have looked into the other similar postings in the same group. But no success. I have not configured a default data source in server.xml and I dont have entries in /WEB-INF/web.xml for this data source

Thanks,
K matt

[ October 19, 2005: Message edited by: k matt ]

[ October 19, 2005: Message edited by: k matt ]

[ October 19, 2005: Message edited by: k matt ]
[ October 19, 2005: Message edited by: k matt ]
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The "No suitable driver" means that it can't find a driver for the URL string you provided.
Double check you have the same url both in the getConnection() call, and in the url of the setDataSource tag. (those "proper arguments" you mentioned.)
 
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is the space in between "jdbc" and "db2" in the url a typo?
[ October 19, 2005: Message edited by: Eddy Lee Sin Ti ]
 
k matt
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That space happened when I cut and pasted to the web. The code which is working as a regular jsp is like this


Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
con = DriverManager.getConnection("jdbc:Db2:mydb","uid","somepassword");

and the using jstl is like this

<sql:setDataSource var="example"
driver="COM.ibm.db2.jdbc.app.DB2Driver"
url="jdbc:Db2:mydb"
user="uid"
password="somepassword" />
<sql:query dataSource="${example}" var="results" >..... </sql:query>


Thanks for looking into this

k Matt

[ October 20, 2005: Message edited by: k matt ]

[ October 20, 2005: Message edited by: k matt ]

[ October 20, 2005: Message edited by: k matt ]
[ October 20, 2005: Message edited by: k matt ]
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, here I come with the wet blanket...

You are spending an enormous amount of time trying to figure out how to do something in a manner that is generally considered extremely poor practice; namely, performing SQL on the pages. Even the framers of the JSTL sql tags recommend that the tags be used only in quick prototypes and not in production code.

I feel that you could be spending your time better by using it to refactor your application into a better structure that follows accepted best practices.
 
k matt
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to do a prototype .

Kurian
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's ok, but do you not think that you are spending way too much time on it? Even in a prototype, I'd spend my time on more useful pursuits. That's just my opinon; it's your decision of course.
 
k matt
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your concern.

k matt
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Matt

You need to have .jar file in your WEB-INF lib.

For example, Oracle db needs classes12.jar in WEB-INF/lib folder.
For DB2 it should be different.

Thanks
SP Nam
 
k matt
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am not getting a ClassNotFoundException. I think the problem I am having is the syntax.

Matt
 
k matt
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
At last the problem is fixed. I took out the var attribute inside sql:setDataSource tag and it works.

Matt
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
BUt how is the problem solved by pushing out var. Plese show the corrected code
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
keep var at the end i.e after user name and passwords it worked for me :jumpingjoy:
 
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
I've been selected to go to the moon! All thanks to this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic