• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSTL SQL setDataSource  RSS feed

 
alex reznik
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can i use same string that i normally use in the DriverManager.getConnection("string") statement in the <sql:setDataSource dataSource="string" /> ?
at this moment, when i do, i get the noSuitableDriver error. any extra steps i need to take for the tag to find the driver besides the regular things that need to be done?(like putting classpath to the .jars)anything specific to the jstl
thanks, alex
 
Shawn Bayern
Author
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by alex reznik:
can i use same string that i normally use in the DriverManager.getConnection("string") statement in the <sql:setDataSource dataSource="string" /> ?
at this moment, when i do, i get the noSuitableDriver error. any extra steps i need to take for the tag to find the driver besides the regular things that need to be done?(like putting classpath to the .jars)anything specific to the jstl
thanks, alex

You can use a JDBC URL (which is what you pass to DriverManager.getConnection(String)) in the JSTL tags' dataSource attribute. However, you need to ensure the driver is loaded. You can specify the driver's class name, preceded by a comma, in the same string. For instance:
dataSource="jdbc:mysql://localhost/,org.gjt.mm.mysql.Driver"
See my book or section 10.1.1 of the JSTL specification (at http://java.sun.com/products/jsp/jstl) for more information.
 
alex reznik
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am using oracle8i, so the connection string for it looks like this:
jdbc racle:thin:user/password@sisi:1521:sisi
now, if i try to insert it into dataSource string and add the driver, i get the following:
<sql:setDataSource dataSource="jdbc racle:thin:user/password@sisi:
1521:sisi,oracle.jdbc.driver.OracleDriver" />; , where the .jar is in the classpath. the error i am getting is:
Unable to get connection, DataSource invalid: "Io exception: The Network Adapter could not establish the connection"
i am mostly concerned with the DataSource invalid part, since i followed the directions...any suggestions i could try?
[ July 08, 2002: Message edited by: alex reznik ]
[ July 08, 2002: Message edited by: alex reznik ]
[ July 08, 2002: Message edited by: alex reznik ]
 
Shawn Bayern
Author
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by alex reznik:
i am using oracle8i, so the connection string for it looks like this:
jdbcracle:thin:user/password@sisi:1521:sisi
now, if i try to insert it into dataSource string and add the driver, i get the following:
<sql:setDataSource dataSource="jdbcracle:thin:user/password@sisi:
1521:sisi,oracle.jdbc.driver.OracleDriver" />; , where the .jar is in the classpath. the error i am getting is:
Unable to get connection, DataSource invalid: "Io exception: The Network Adapter could not establish the connection"
i am mostly concerned with the DataSource invalid part, since i followed the directions...any suggestions i could try?

"DataSource invalid" just means that there was some error accessing the database using the string that you provided. In this case, the more detailed error is reported: your JSP server couldn't establish a connection with your database. Try using a full hostname instead of 'sisi' as the name of the server in the URL; JDBC doesn't have access to the TNS resolver.
 
alex reznik
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
cool thanks for your help, everything is working
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!