FatalErrorGuy
Programmer
Hi everyone,
I'm trying to get Tomcat 5.0.28 to work with mysql. It works fine if I define the datasource in the actual JSP like this:
<sql:setDataSource var="ADataSource"
url="jdbc:mysql://localhost:3306/javatest" driver="com.mysql.jdbc.Driver" user="myusername" password="myusername"/>
However, I can't for the life of me get it to work by defining the datasource in a context.xml. I made a subdirectory called META-INF and put a context.xml file in there with the following:
<Context path="/" docBase="webapps/ROOT" debug="1" reloadable="true">
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="localhost_DBTest_log." suffix=".txt"
timestamp="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>
<parameter>
<name>username</name>
<value>myusername</value>
</parameter>
<parameter>
<name>password</name>
<value>mypassword</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<parameter>
<name>url</name> <value>jdbc:mysql://localhost:3306/javatest</value>
</parameter>
</ResourceParams>
</Context>
I keep getting this error:
javax.servlet.ServletException: Unable to get connection, DataSource invalid: "java.sql.SQLException: No suitable driver"
I've tried putting the context.xml file under a subdirectory called META-INF, as well as in my $CATALINA_HOME/conf/Catalina/localhost/ directory as a file called test1c.xml (since the file is test1c.jsp).
I've tried playing with the docBase settings,etc.
Right now my goal is to figure out some way to know for certain if Tomcat is recognizing my context.xml. For example, I'd like to make a JSP that displays a value from the context.xml file so I can tell if it's working.
Has anyone had trouble getting context.xml to work?
Does anyone know how to display a Resource value from context.xml?
Thank you so much in advance!!
Mike
I'm trying to get Tomcat 5.0.28 to work with mysql. It works fine if I define the datasource in the actual JSP like this:
<sql:setDataSource var="ADataSource"
url="jdbc:mysql://localhost:3306/javatest" driver="com.mysql.jdbc.Driver" user="myusername" password="myusername"/>
However, I can't for the life of me get it to work by defining the datasource in a context.xml. I made a subdirectory called META-INF and put a context.xml file in there with the following:
<Context path="/" docBase="webapps/ROOT" debug="1" reloadable="true">
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="localhost_DBTest_log." suffix=".txt"
timestamp="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>
<parameter>
<name>username</name>
<value>myusername</value>
</parameter>
<parameter>
<name>password</name>
<value>mypassword</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<parameter>
<name>url</name> <value>jdbc:mysql://localhost:3306/javatest</value>
</parameter>
</ResourceParams>
</Context>
I keep getting this error:
javax.servlet.ServletException: Unable to get connection, DataSource invalid: "java.sql.SQLException: No suitable driver"
I've tried putting the context.xml file under a subdirectory called META-INF, as well as in my $CATALINA_HOME/conf/Catalina/localhost/ directory as a file called test1c.xml (since the file is test1c.jsp).
I've tried playing with the docBase settings,etc.
Right now my goal is to figure out some way to know for certain if Tomcat is recognizing my context.xml. For example, I'd like to make a JSP that displays a value from the context.xml file so I can tell if it's working.
Has anyone had trouble getting context.xml to work?
Does anyone know how to display a Resource value from context.xml?
Thank you so much in advance!!
Mike