Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

MySQL Connection Problem

Hello all,

I am trying to establish connection to MySQL database through a service but getting an error
"java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
"

I have copied Connector/J jar in my Jazz/JVM install directory.

--------------------
Here is my connectivity code in .java file.

String url = "jdbc:mysql://localhost:3000/";
String dbName = "common";
String driver = "com.mysql.jdbc.Driver";
String userName = "root";
String password = "qwerty";

try {
writer.println("In try block");
Class.forName(driver).newInstance();

conn = DriverManager.getConnection(url+dbName,userName,password);
writer.println("Connected to the database");
conn.close();
writer.println("Disconnected from database");
}

catch (Exception e)
{
writer.println(e);
}

0 votes



3 answers

Permanent link
You are playing with fire <g> We don't support doing this, so you are really on your own here.

The server runs as plug-ins, you can't use Class.forName() without providing access to classpaths from dependent plug-ins. There are examples in our source code about how we do this. If you dig enough you'll find it.

Jean-Michel

0 votes


Permanent link
You may want to consider subscribing to Enhancement 43396:"add support
for storing the repository DB in MySQL"

mapagile_tcs wrote:
Hello all,

I am trying to establish connection to MySQL database through a
service but getting an error
"java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
"

I have copied Connector/J jar in my Jazz/JVM install directory.

--------------------
Here is my connectivity code in .java file.

String url = "jdbc:mysql://localhost:3000/";
String dbName = "common";
String driver = "com.mysql.jdbc.Driver";
String userName = "root";
String password = "qwerty";

try {
writer.println("In try block");
Class.forName(driver).newInstance();

conn = DriverManager.getConnection(url+dbName,userName,password);
writer.println("Connected to the database");
conn.close();
writer.println("Disconnected from database");
}

catch (Exception e)
{
writer.println(e);
}

0 votes


Permanent link
Thanks a lot for your reply. :)

I have copied the Connector Jar file to JVM folders of both client and server, even have tried adding the CLASSPATH of JAR file to arguments of launch config. But it dint worked out. I am unable to figure out how to register MySQL Connector Jar so that it can be used with Class.forName().

I tried connecting with MS Access DB and it worked but I am facing the same problem with Oracle database and its Connector JAR file.

Can you please help me out in this issue.

Thanks in advance.

You are playing with fire <g> We don't support doing this, so you are really on your own here.

The server runs as plug-ins, you can't use Class.forName() without providing access to classpaths from dependent plug-ins. There are examples in our source code about how we do this. If you dig enough you'll find it.

Jean-Michel

0 votes

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details

Question asked: May 27 '08, 1:26 a.m.

Question was seen: 3,997 times

Last updated: May 27 '08, 1:26 a.m.

Confirmation Cancel Confirm