facebook

DB Connection: Deploy works in Tomcat, not in Resin

  1. MyEclipse IDE
  2.  > 
  3. General Development
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #205039 Reply

    dand9959
    Member

    I have a very simple test application that simply connects to a mysql DB in a bean and prints some data via a jsp.

    The deployed app works fine in Tomcat, but not in Resin – the java.com.env/jdbc/TestDB resource is not found in Resin?

    In tomcat, I place a context.xml for the db resource under the TOMCAT_HOME/conf directory, and name it myApp.xml

    I’ve tried placing that file in a number of places under resin, but cannot get the resource recognized.

    The Resin docs descirbe a <database> descriptor to use in the app”s web.xml, but Eclipse barfs at the syntax.

    Does anyone know what I’ve done incorrectly?

    The xml file I use is boilerplate that myEclipse users should recognize:

    <Context path=”/TestDB” docBase=”TestDB” debug=”5″ reloadable=”true” crossContext=”true”>

    <Resource name=”jdbc/TestDB”
    auth=”Container”
    type=”javax.sql.DataSource”/>

    <ResourceParams name=”jdbc/TestDB”>
    <parameter>
    <name>factory</name>
    <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
    </parameter>

    <!– Maximum number of dB connections in pool. Make sure you
    configure your mysqld max_connections large enough to handle
    all of your db connections. Set to 0 for no limit.
    –>
    <parameter>
    <name>maxActive</name>
    <value>100</value>
    </parameter>

    <!– Maximum number of idle dB connections to retain in pool.
    Set to 0 for no limit.
    –>
    <parameter>
    <name>maxIdle</name>
    <value>30</value>
    </parameter>

    <!– Maximum time to wait for a dB connection to become available
    in ms, in this example 10 seconds. An Exception is thrown if
    this timeout is exceeded. Set to -1 to wait indefinitely.
    –>
    <parameter>
    <name>maxWait</name>
    <value>10000</value>
    </parameter>

    <!– MySQL dB username and password for dB connections –>
    <parameter>
    <name>username</name>
    <value>enfora</value>
    </parameter>
    <parameter>
    <name>password</name>
    <value>pinehurst</value>
    </parameter>

    <!– Class name for mm.mysql JDBC driver –>
    <parameter>
    <name>driverClassName</name>
    <value>com.mysql.jdbc.Driver</value>
    </parameter>

    <!– The JDBC connection url for connecting to your MySQL dB.
    The autoReconnect=true argument to the url makes sure that the
    mm.mysql JDBC Driver will automatically reconnect if mysqld closed the
    connection. mysqld by default closes idle connections after 8 hours.
    –>
    <parameter>
    <name>url</name>
    <value>jdbc:mysql://localhost:3306/myTestDB?autoReconnect=true</value>
    </parameter>
    </ResourceParams>
    </Context>

    #205043

    Riyad Kalla
    Member

    To setup your JNDI context for the database connection you need to add the <database> tag you were looking at into the resin.conf file (this is what I understand from my limited reading of the Resin docs)

    If I am wrong, someone please correct me.

    #206080

    Albren
    Member

    Hi dand,

    I have a problem but not really related to the one you are asking.
    Im having error “Access denied with mySQL with password YES” (Something like this)
    How to setup properly the mySQL. Thanks.

    #206085

    Riyad Kalla
    Member

    Albren,
    This is definately out of the scope of these forums, but let me give you some tips to get started:

      1) Download MySQL CC, its a great tool for managing MySQL http://dev.mysql.com/downloads/mysqlcc.html
      2) Connect MySQLL CC to your local running instance of MySQL
      3) Double click to expand the User Administrator node
      4) Add a new user, name them something useful like “devUser”, set their host name to “localhost” and set a password. ALso make sure to check the DB you want them to have access to and what permissions you want to give them. Hit Add.
      5) Optionally you can keep this screen open and change “localhost” to “%” (w/o quotes) this allows this same user to connect FROM any where else.
      6) Update your JNDI context in Tomcat to use this new login name/password.
Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: DB Connection: Deploy works in Tomcat, not in Resin

You must be logged in to post in the forum log in