In case anyone else runs into the following error message:
Error: DBCP borrowObject failed: java.sql.SQLException: Server connection
failure during >transaction
The cause of the error was the mysql user I was using to access the database didn't have permission
to access it.
The JNIDI Datasource howto has you create a user called "javauser" in your mysql database
with the following command:
GRANT ALL PRIVILIGES ON *.* TO javauser@localhost IDENTIFIEd BY 'javadude' WITH GRANT OPTION;
Since, the MySQL setup I was using had entries in the mysql system database table "db" restricting
users to certain databases. I also had to add the "javauser" to this table and give the user
permission to access the "javatest" table.
Don
-----Original Message-----
From: Don Ross
Sent: Thursday, July 31, 2003 5:59 PM
To: Tomcat Users List
Subject: RE: Problem confinguring MySQL JNDI Datasource RH Linux 7.2
Scott,
I tried your suggestion and I am still getting the same error.
Below is the log from the context DBTest, which I setup to use the datasource.
I tried another suggestion from following URL:
http://www.java-internals.com/code/resourcefactory/readme.html
which also defined the datasource <GlobalNamingResources> section and got a little further.
The java-internals suggestion uses a different resource type and added a factory parameter
that references a jar file that I had to install in $CATALINA_HOME/common/lib/
After tryig their suggestion I following error:
java.sql.SQLException: Invalid authorization specification: Access denied for user: 'nobody@127.0.0.1'
(Using password: YES) error
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:659)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:1562)
at com.mysql.jdbc.Connection.<init>(Connection.java:491)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:346)
at com.mysql.jdbc.jdbc2.optional.MysqlDataSource.getConnection(MysqlDataSource.java:199)
at com.mysql.jdbc.jdbc2.optional.MysqlDataSource.getConnection(MysqlDataSource.java:163)
at com.mysql.jdbc.jdbc2.optional.MysqlDataSource.getConnection(MysqlDataSource.java:134)
at foo.DBTest.init(DBTest.java:23)
Doesn't look like my user and password parameters are getting processed
Here are the sections I updated:
<ResourceLink name="jdbc/MySQLConnectPool"
global="jdbc/MySQLConnectPool"
type="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource" />
<Resource name="jdbc/MySQLConnectPool"
auth="Container"
type="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource"
/>
<ResourceParams name="jdbc/MySQLConnectPool" >
<parameter>
<name>factory</name>
<value>com.java_internals.resourcefactory.MyResourceFactory</value>
</parameter>
<parameter>
<name>serverName</name>
<value>localhost</value>
</parameter>
<parameter>
<name>databaseName</name>
<value>javatest</value>
</parameter>
<parameter>
<name>username</name>
<value>javauser</value>
</parameter>
<parameter>
<name>password</name>
<value>javadude</value>
</parameter>
</ResourceParams>
<DBTest log file after I implemented your changes>
2003-07-31 17:10:14 StandardContext[/DBTest]: Starting
2003-07-31 17:10:14 StandardContext[/DBTest]: Processing start(), current available=false
2003-07-31 17:10:14 StandardContext[/DBTest]: Configuring default Resources
2003-07-31 17:10:14 StandardContext[/DBTest]: Configuring non-privileged default Loader
2003-07-31 17:10:14 StandardContext[/DBTest]: Configuring default Manager
2003-07-31 17:10:14 StandardContext[/DBTest]: Processing standard container startup
2003-07-31 17:10:14 WebappLoader[/DBTest]: Deploying class repositories to work directory
/usr/local/jakarta-tomcat-4.1.24/work/Standalone/localhost/DBTest
2003-07-31 17:10:14 WebappLoader[/DBTest]: Deploy class files /WEB-INF/classes to /usr/local/jakarta-tomcat-4.1.24/webapps/DBTest/WEB-INF/classes
2003-07-31 17:10:14 WebappLoader[/DBTest]: Reloading checks are enabled for this Context
2003-07-31 17:10:14 ContextConfig[/DBTest]: ContextConfig: Processing START
2003-07-31 17:10:14 StandardContext[/DBTest]: Setting deployment descriptor public ID to '-//Sun
Microsystems, Inc.//DTD Web Application 2.3//EN'
2003-07-31 17:10:14 StandardContext[/DBTest]: Setting deployment descriptor public ID to '-//Sun
Microsystems, Inc.//DTD Web Application 2.3//EN'
2003-07-31 17:10:14 ContextConfig[/DBTest]: Accumulating TLD resource paths
2003-07-31 17:10:14 ContextConfig[/DBTest]: Scanning <taglib> elements in web.xml
2003-07-31 17:10:14 ContextConfig[/DBTest]: Scanning TLDs in /WEB-INF subdirectory
2003-07-31 17:10:14 ContextConfig[/DBTest]: Scanning JARs in /WEB-INF/lib subdirectory
2003-07-31 17:10:14 ContextConfig[/DBTest]: Pipline Configuration:
2003-07-31 17:10:14 ContextConfig[/DBTest]: org.apache.catalina.core.StandardContextValve/1.0
2003-07-31 17:10:14 ContextConfig[/DBTest]: ======================
2003-07-31 17:10:14 NamingContextListener[/Standalone/localhost/DBTest]: Creating JNDI naming
context
2003-07-31 17:10:14 NamingContextListener[/Standalone/localhost/DBTest]: Resource parameters
for jdbc/MySQLConnectPool = null
2003-07-31 17:10:14 NamingContextListener[/Standalone/localhost/DBTest]: Adding resource
link jdbc/MySQLConnectPool
2003-07-31 17:10:14 NamingContextListener[/Standalone/localhost/DBTest]: Resource parameters
for UserTransaction = null
2003-07-31 17:10:14 StandardManager[/DBTest]: Seeding random number generator class java.security.SecureRandom
2003-07-31 17:10:15 StandardManager[/DBTest]: Seeding of random number generator has been
completed
2003-07-31 17:10:15 StandardContext[/DBTest]: Posting standard context attributes
2003-07-31 17:10:15 StandardContext[/DBTest]: Configuring application event listeners
2003-07-31 17:10:15 StandardContext[/DBTest]: Sending application start events
2003-07-31 17:10:15 StandardContext[/DBTest]: Starting filters
2003-07-31 17:10:15 StandardWrapper[/DBTest:default]: Loading container servlet default
2003-07-31 17:10:15 StandardWrapper[/DBTest:invoker]: Loading container servlet invoker
2003-07-31 17:10:15 StandardContext[/DBTest]: Starting completed
2003-07-31 17:11:10 StandardContext[/DBTest]: Mapping contextPath='/DBTest' with requestURI='/DBTest/test.jsp'
and relativeURI='/test.jsp'
2003-07-31 17:11:10 StandardContext[/DBTest]: Trying exact match
2003-07-31 17:11:10 StandardContext[/DBTest]: Trying prefix match
2003-07-31 17:11:10 StandardContext[/DBTest]: Trying extension match
2003-07-31 17:11:10 StandardContext[/DBTest]: Mapped to servlet 'jsp' with servlet path '/test.jsp'
and path info 'null' and update=true
</DBTest log file>
Thanks for the help,
Don
-----Original Message-----
From: Scott Stewart [mailto:SStewart@csky.com]
Sent: Thursday, July 31, 2003 2:45 PM
To: 'Tomcat Users List'
Subject: RE: Problem confinguring MySQL JNDI Datasource RH Linux 7.2
You certainly can define your MySQL JNDI Datasource within the
<GlobalResourceParams> node in server.xml. This is how I have it set up
currently and everything works fine (I am running Tomcat 4.1.24). I sent
the following out the other day in response to a different thread, but it
applies here as well:
The global DataSource definition
--------------------------------
<!-- Global JNDI resources -->
<GlobalNamingResources>
<!-- Editable user database that can also be used by JNDI
DatabaseRealm to authenticate users -->
<Resource name="jdbc/MySQLConnectPool"
auth="Container"
type="javax.sql.DataSource" />
<ResourceParams name="jdbc/MySQLConnectPool" >
<parameter>
<name>username</name>
<value>????????</value>
</parameter>
<parameter>
<name>password</name>
<value>????????</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://<your IP here>:3306/<your DB name
here>?autoReconnect=true</value>
</parameter>
<parameter>
<name>removeAbandoned</name>
<value>true</value>
</parameter>
<parameter>
<name>removeAbandonedTimeout</name>
<value>60</value>
</parameter>
<parameter>
<name>logAbandoned</name>
<value>true</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>200</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>30000</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>100</value>
</parameter>
</ResourceParams>
</GlobalNamingResources>
Realm definition using global DataSource
----------------------------------------
<Realm
className="org.apache.catalina.realm.DataSourceRealm"
dataSourceName="jdbc/MySQLConnectPool"
userTable="customers"
userNameCol="customer_username"
userCredCol="customer_password"
userRoleTable="roles"
roleNameCol="role"
debug="0"
/>
Context reference to global DataSource
--------------------------------------
<ResourceLink name="jdbc/MySQLConnectPool"
global="jdbc/MySQLConnectPool"
type="javax.sql.DataSource" />
Hope this helps!!
Thanks,
Scott Stewart
-----Original Message-----
From: Geralyn M Hollerman [mailto:gmh2441@louisiana.edu]
Sent: Thursday, July 31, 2003 1:24 PM
To: tomcat-user@jakarta.apache.org
Subject: Re: Problem confinguring MySQL JNDI Datasource RH Linux 7.2
dross@leds.com wrote:
> I have followed instructions provided for configuring JNDI Datasource for
MySQL
(http://jakarta.apache.org/tomcat/tomcat-4.1-doc/printer/jndi-datasource-exa
mples-howto.html), and am running into problem on RedHat Linux 7.2.
>
> Here is my configuration:
>
> RedHat Linux 7.2 (kernel-2.4.7-10)
> Tomcat 4.1.24 (Clean install)
> MySQL 4.0.12
> Using mysql-connector-java-3.0.8-stable-bin.jar (driver installed in
$CATALINA_HOME/common/lib/)
>
> I copied the example code straight from the URL and made following change
to DBTest context for >my system and mysql driver.
>
> <server.xml snippet>
> !-- 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://<dns name of
system>:3306/javatest?autoReconnect=true</value>
> </parameter>
> </ResourceParams>
> </server.xml snippet>
>
> I get following error in catalina.out when bringing up test.jsp that uses
the datasource.
>
> <catalina.out error>
> DBCP borrowObject failed: java.sql.SQLException: Server connection
failure during >transaction.
>
> Does any one have any advice on what may be wrong?
>
> I have successfully configured Tomcat 4.1.24 using the JNDI datasource
howto example code on >Windows 2000 using
mysql-connector-java-3.0.8-stable-bin.jar, with MySQL 3.23.44.
Is that server.xml snippet in <GlobalResourceParams> or its own
<Context>? It needs to be in its own <Context>. Also, where are your
username and password defined? I'm using 4.1.24, and I get a message in
catalina.out if I leave those out (they should be defined in the
<ResourceParams> as parameters). According to some other questions I've
seen about this, that error often comes up due to a permissions problem
with MySQL - does the user you're using have access rights (in MySQL)
for the db?
--
Lynn Hollerman.
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
|