Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Websphere and the fly likes SQLException in connecting to mysql Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Websphere
Bookmark "SQLException in connecting to mysql" Watch "SQLException in connecting to mysql" New topic
Author

SQLException in connecting to mysql

mkoliop juiok
Greenhorn

Joined: Sep 29, 2005
Posts: 4
Hi All

I am trying to connect to mysql 4.1 through WSAD but I am getting the following errors:

java.sql.SQLException: Cannot load connection class because of underlying exception: 'java.lang.SecurityException: Prohibited package name: java.util'.
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:273)
at java.sql.DriverManager.getConnection(DriverManager.java:543)
at java.sql.DriverManager.getConnection(DriverManager.java:216)
at cdmanager.util.DbUtil.connectToDb(DbUtil.java:22)
at cdmanager.util.DbUtil.main(DbUtil.java:38)
Error connecting to database

My code is:
package cdmanager.util;

import java.sql.Connection;
import java.sql.DriverManager;

public class DbUtil {
static Connection connection;
static String driverName="org.gjt.mm.mysql.Driver";
static String dbUrl="jdbc:mysql://localhost/cdsample";


public DbUtil() {

}


public static java.sql.Connection connectToDb()
{

try
{

//Class.forName("org.gjt.mm.mysql.Driver").newInstance();
Class.forName("com.mysql.jdbc.Driver").newInstance();

Connection connection = DriverManager.getConnection("jdbc:mysql://localhost/cdsample?user=guest&password=guest");

}
catch(Exception e)
{


System.err.println("Connection name = " + dbUrl);
e.printStackTrace(System.out);
}
return connection;
}

public static void main(String[] args)
{
//Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection c=connectToDb();
if (c==null)
System.out.println("Error connecting to database");
else
System.out.println("connected to database");
}

}

I am using mysql-connector-java-3.1.10(mysql-connector-java-3.1.10-bin.jar).

Is this a bug??

Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SQLException in connecting to mysql
 
Similar Threads
connect my MySQl databse
SQLException in connecting to mysql
HTTP method GET is not supported by this URL
JDBC MySQL Driver Connection
JDBC for MySQL