• 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
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

JSTL SQL setDataSource

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Author
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by alex reznik:
i am using oracle8i, so the connection string for it looks like this:
jdbc:oracle: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:oracle: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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
cool thanks for your help, everything is working
 
No matter how many women are assigned to the project, a pregnancy takes nine months. Much longer than this tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic