• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jstl:sql no suitable driver error

 
k matt
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • 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 ]
 
Stefan Evans
Bartender
Posts: 1780
10
  • Mark post as helpful
  • send pies
  • 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.)
 
Eddy Lee Sin Ti
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • 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
  • 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("jdbcb2:mydb","uid","somepassword");

and the using jstl is like this

<sql:setDataSource var="example"
driver="COM.ibm.db2.jdbc.app.DB2Driver"
url="jdbcb2: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 ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65120
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
I am trying to do a prototype .

Kurian
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65120
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thank you for your concern.

k matt
 
SP Nam
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
 
Chirags Jain
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
BUt how is the problem solved by pushing out var. Plese show the corrected code
 
dinesh kumary
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
keep var at the end i.e after user name and passwords it worked for me :jumpingjoy:
 
Albareto McKenzie
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic