Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Database connection error with JSP

843836Feb 14 2005 — edited Feb 14 2005
I'm having problems connecting to a mysql database via a helper object in my jsp pages. I've researched this for the last two days and nothing I have tried is yet to make a difference.

My java code is essentially the following (minus try/catch for readability):
     Connection con = null;
     String dsn = "jdbc:odbc:mwtech";
     String user = "root";
     String password = "";
     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
     con = DriverManager.getConnection(dsn, user, password);
When I run this via JBuilder, it connects to my database without a problem. But when I try to use this same object via a jsp I keep getting the error:
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified .

I'm running Tomcat 4.1 as my web-server, my database is named mwtech and has a User DSN registered in the ODBC panel.

I've made the following alterations to my server.xml and web.xml files:

server.xml
<Context path="" reloadable="true" docBase="ROOT" debug="0" >
	<ResourceParams name="jdbc/mwtech">
    	<parameter>
      		<name>driverClassName</name>
      		<value>sun.jdbc.odbc.JdbcOdbcDriver</value>
    	</parameter>

    	<parameter>
      		<name>url</name>
      		<value>jdbc:odbc:mwtech</value>
    	</parameter>

    	<parameter>
      		<name>user</name>
      		<value>root</value>
    	</parameter>
    	<parameter>
      		<name>password</name>
      		<value></value>
    	</parameter>
	 </ResourceParams>

</Context>

WEB-INF\web.xml
<resource-ref>
<res-ref-name>jdbc/odbc</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>


I have also tried configuring this to work with the mysql connector/J driver, but that didn't work either (in fact, it made things worse so it won't even run via JBuilder).

Any help would be greatly appreciated.

--Slowly going insane...
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 14 2005
Added on Feb 14 2005
1 comment
435 views