Jdbc

apffal

Registered
When trying a search in a JDBC application compiled with Xcode, I cannot connnect to a Mysql database and I receive the following message :

ClassNotFoundException: com.mysql.jdbc.Driver
Trying to connect...
apple.awt.EventQueueExceptionHandler Caught Throwable : java.lang.NullPointerException

However, I can load Mysql driver and connect to the same database in other JDBC application, compiled with javac in command line

What's wrong ?
Thanks
 
When you talk about the application that is compiled from the command line, is this the _exact_ same application that was compiled via Xcode?
 
Where is the mysql JDBC driver located? If it is in a JAR file, you need to make sure that it is included in the classpath when you execute it from within Xcode. That is what the error message is saying: it can't find the mysql jdbc driver.
 
I put the driver "jar" file in my home directory and its classpath in a ".profile" file, that points to it.
And all this works when the application is compiled on command line.
Why not with Xcode ?
Must I put driver "jar" file in java "ext" directory ?
 
Modifications to the .profile will only work if a shell is launched. Since you are not launching a shell but are running directly from Xcode, you can see why it isn't working.

To set the classpath in Xcode, expand the Targets group (in the left pane). Double click Executables. Click + under Environment Variables and add the classpath. You should be set :).
 
Back
Top