Skip to content
Advertisement

Cannot create JDBC driver of class ‘ ‘ for connect URL ‘null’ : I do not understand this exception

Why does it say null URL and gives a empty ‘ ‘ class in the exception when I have provided the database URL?

I am trying to connect to a derby database via a servlet while using Tomcat. When the servlet gets run, I get the following exceptions:

JavaScript

Servlet :

JavaScript

What exception is this? Why do I get this exception?

I have added the following tag in context.xml of Tomcat :

JavaScript

and this in web.xml :

JavaScript

Where am I making a mistake?

Image that shows the database URL..

enter image description here

NOTE : After the answer by @Bryan Pendleton I changed the driver to org.apache.derby.jdbc.ClientDriver but I get the same exception.

Advertisement

Answer

I can’t see anything obviously wrong, but perhaps a different approach might help you debug it?

You could try specify your datasource in the per-application-context instead of the global tomcat one.

You can do this by creating a src/main/webapp/META-INF/context.xml (I’m assuming you’re using the standard maven directory structure – if not, then the META-INF folder should be a sibling of your WEB-INF directory). The contents of the META-INF/context.xml file would look something like:

JavaScript

Obviously the path and docBase would need to match your application’s specific details.

Using this approach, you don’t have to specify the datasource details in Tomcat’s context.xml file. Although, if you have multiple applications talking to the same database, then your approach makes more sense.

At any rate, give this a whirl and see if it makes any difference. It might give us a clue as to what is going wrong with your approach.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement