Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] Configuring Eclipse Jetty 8.1.5, MySQL 5.1 aka (where the <bleep> does a <resource-ref> go?)

I'm struggling, so far in vain, to get database connection pooling working on Jetty.

I've read *lots* of web pages, and they all have something different to say about how to configure this.

I've ended up trying to configure a servlet via its gcm.xml file like so:

|<?xml version="1.0"   encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd";>
<Configure  id="wac"  class="org.eclipse.jetty.webapp.WebAppContext">
  <New  id="jdbc/myds"  class="org.eclipse.jetty.plus.jndi.Resource">
    <Arg></Arg>
    <Arg>jdbc/myds</Arg>
    <Arg>
      <New  class="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource">
        <Set  name="Url">jdbc:mysql://localhost:3306/chat</Set>
        <Set  name="User">root</Set>
        <Set  name="Password">sillyness</Set>
      </New>
    </Arg>
  </New>
  <Set  name="contextPath">/</Set>
  <Set  name="war"><SystemProperty  name="jetty.home"  default="."/>/webapps/gcm</Set>
  <Set  name="extractWAR">true</Set>
</Configure>|


My servlet gets called like this:

|  public  static  List<String>  getDevices()
    throws  javax.naming.NamingException,  java.sql.SQLException  {
    synchronized  (regIds)  {
        InitialContext  ctx=  new  InitialContext();
        DataSource  ds=  (DataSource)ctx.lookup("java:comp/env/jdbc/myds");
        Connection  conn=  null;
        Statement  stmt=  null;

        try  {
            conn=  ds.getConnection();

            stmt=  conn.createStatement();
            ResultSet  rs=  stmt.executeQuery("select * from chatdevice");

        //blah,blah,blah...
|


And all the documents I've seen suggest that I need to put a <resource-ref> section in my web.xml file...which of course doesn't exist.

If I put the <resource-ref> in the gcm.xml file (anywhere), or if I put it into a web.xml file on its own, I'm told the file is not well formed.

Can anyone tell me the magic combination to get it to work?

Thanks,

-Ken


Back to the top