It's all about the answers!

Ask a question

MySQL Connection Problem


MAPAGILE MAPAGILE (81225) | asked May 27 '08, 1:26 a.m.
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);
}

3 answers



permanent link
Jean-Michel Lemieux (2.5k11) | answered May 27 '08, 8:01 a.m.
JAZZ DEVELOPER
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

permanent link
Aaron Cohen (8207851) | answered May 27 '08, 9:26 a.m.
JAZZ DEVELOPER
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);
}

permanent link
MAPAGILE MAPAGILE (81225) | answered May 28 '08, 12:43 a.m.
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

Your answer


Register or 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.