Skip to Main Content

Java Database Connectivity (JDBC)

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!

MySql database Connection failure

843854Dec 1 2004 — edited Dec 2 2004
Hi,

I have following code. I am using MySql database. and Tomcat server and MySql jdbc driver. I am able to get the Datasource but when I call getConnection on ds, I get Connection object as null. Any help here?
			ctx = new InitialContext();
			if( ctx == null ) throw new Exception("ERROR - No Context");

			//**************************//
			// ESTABLISH THE DataSource //
			//**************************//
						ds = (DataSource)ctx.lookup("java:comp/env/jdbc/xmediaDB");
			if( ds == null ) throw new Exception("ERROR - DataSource is null");

			//**************************//
			// ESTABLISH THE Connection //
			//**************************//
			con = ds.getConnection();
			if( con == null ) throw new Exception("ERROR - Failed to get connection");
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 30 2004
Added on Dec 1 2004
8 comments
262 views