• 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

driverName or URL or ..., plz help

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i read the professional java servlet 2.3from wrox press & got stuck in ch.8
my configuration in server.xml:
<Context path="/inventory" docBase="inventory">
<Resource name="jdbc/inventoryDB" auth="Container"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/inventoryDB">
<parameter><name>username</name><value>root</value></parameter>
<parameter><name>password</name><value>******</value></parameter>
<parameter>
<name>driverClassName</name>
<value>org.gjt.mm.mysql.Driver</value>
</parameter>
<parameter>
<name>driverName</name>
<value>jdbc:mysql://localhost:3306/inventory</value>
</parameter>
</ResourceParams>
</Context>
but it complaint:
java.sql.SQLException: Cannot create JDBC driver of class 'org.gjt.mm.mysql.Driver' for connect URL 'null'
i tried replacing the driverName w/ url, but it throws:
java.lang.UnsupportedOperationException
at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:125)
what's the difference between 'driverName' & 'url'??
i'm using tomcat4.1.27, mysql 4.0.16
anybody experienced this before?
plz help
 
Ranch Hand
Posts: 541
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i do not know this book but i think you have probably miss named some of those parameters.
it looks like you are missing the parameter for the URL/URI but have called it something else. the url/uri is this jdbc:mysql://localhost:3306/inventory . this tells the driver where the database. i'm thinking maybe driverName is some sort of shorthand reference you can create for the classname?
you may need to post the db connection java code if you want more help unless someone knows this book ?
 
g wong
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thx anyway~
i use JNDI to set the data src used to acquire connection, & for setting SQL command
string, as instructed by the book
here's the code i think that is used to connect the db:
try {
RowSet rs = new CachedRowSet();
rs.setDataSourceName("java:comp/env/jdbc/inventoryDB");
rs.setCommand("select * from item");
rs.execute();
req.setAttribute("rs", rs);

getServletContext().getRequestDispatcher("/List.jsp").
forward(req, res);
} catch(Exception ex) {
throw new ServletException(ex);
}
btw, i use CachedRowSet(sun.jdbc.rowset.CachedRowSet). does it matter??
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
here are tomcat-specific docs on datasource setup.
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html

So I second Tim's notion of renaming 'driverName' to 'url' (even though you say that throws an exception, it's the correct configuration).

I'd also suggest a more recent driver class, namely "com.mysql.jdbc.Driver", instead of "org.gjt.mm.mysql"

And of course, your connectorj.jar file should be in WEB-INF/lib (or common/lib)
 
g wong
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thx, Mike
i followed yr instruction:
1) changed org.gjt.mm.mysql.Driver to com.mysql.jdbc.Driver
2) put rowset.jar in WEB-INF/lib or common/lib // i tried both
but it still throws:
java.lang.UnsupportedOperationException
at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:125)
any idea?
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it could be the CachedRowSet.

have you tried:

rs.setDataSourceName("jdbc/inventoryDB");
 
g wong
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thx, Mike
but after i followed yr instruction, it throws
java.sql.SQLException: (JNDI) Unable to connect
at sun.jdbc.rowset.RowSetReaderImpl.connect(RowSetReaderImpl.java:222)
at sun.jdbc.rowset.RowSetReaderImpl.readData(RowSetReaderImpl.java:115)
at sun.jdbc.rowset.CachedRowSet.execute(CachedRowSet.java:712)
at sun.jdbc.rowset.CachedRowSet.execute(CachedRowSet.java:1185)
i think the original JNDI name of the data src might be correct
any idea?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic