The moose likes JDBC and the fly likes JDBC_MySQL - Driver not possible to load Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JDBC
Reply Bookmark "JDBC_MySQL - Driver not possible to load" Watch "JDBC_MySQL - Driver not possible to load" New topic
Author

JDBC_MySQL - Driver not possible to load

Jobst
Greenhorn

Joined: Apr 03, 2002
Posts: 2
I want to connect MySQL with Java. To compile the Java- application is no problem. But to execute the application is not possible, I always get the message that the driver cannot be found.
I use a type 4 driver (for MySQL) from TcXDatakonsultAB. (From the installation instructions) I've used Class.forName("twz1.jdbc.mysql.jdbcMysqlDriver");
and the URL jdbc:z1MySQL: . I also tried several different possibilities of writing the CLASSPATH.
I've read a lot of tutorials and installation instructions but cannot find the solution, why the application cannot find the driver .....
Is there anyone who can help me ?
Many Thanks,

Jobst
Jobst
Greenhorn

Joined: Apr 03, 2002
Posts: 2
HELLLO !
I think it's the best that I send the application I use.
It's an application from Sun's Java-Tutorial for trying
out and to learn. Compiling is no problem, only to execute
the application is not possible, I always
get the message that the driver cannot be found.
The 'jar.'-DriverFile is located in my Java-directory under
jre/lib/ext.
Well, I think this is really hard stuff !!!
I talked with some people about this problem, but until now
nobody could help me ...
Any help or ideas you have is welcome !
I thank you !
Greetings, Jobst ;-)
import java.sql.*;

public class CreateCoffees {
public static void main(String args[]) {

String url = "jdbc:z1MySQL:myDataSource";
Connection con;
String createString;
createString = "create table COFFEES " +
"(COF_NAME varchar(32), " +
"SUP_ID int, " +
"PRICE float, " +
"SALES int, " +
"TOTAL int)";
Statement stmt;

try {
Class.forName("twz1.mysql.jdbcMysqlDriver");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection
(url, "myLogin", "myPassword");

stmt = con.createStatement();
stmt.executeUpdate(createString);

stmt.close();
con.close();

} catch(SQLException ex) {
System.err.println
("SQLException: " + ex.getMessage());
}
}
}
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

What is the "twz1.jdbc.mysql.jdbcMysqlDriver" driver? I'm not familiar with it. The most common driver used with MySQL is the mm.mysql driver available from http://www.worldserver.com/mm.mysql/
One thing to check is that you are unpacking the drivers correctly. For example, I think the mm.mysql drivers are supplied as a jar, but you have to unjar the initial level (which also contains the source and sample code) to get to the real jar that you put on your classpath.
Another thing I'd check is that you can get to the drivers via 'javap'. ie if your program can get the drivers you should also be able to get to them with 'javap twz1.jdbc.mysql.jdbcMysqlDriver'
If you are trying to run it in an application server, everything may be different and none of the above will be helpful...
You may find you have a better chance of response if you have a name that conforms to the JavaRanch naming convention, described at http://www.javaranch.com/name.jsp.
We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please edit your profile and select a new name which meets the requirements.
Thanks.
Dave


[ JavaRanch FAQ ][ Book Promotions ][ DbTamer ][ BumperStickers ][ JavaRanch Badges ]
Tejeshwara Murthy K.G
Greenhorn

Joined: Apr 08, 2002
Posts: 4
Hi
I don't know whether u r trying to connect in Windows or Linux. Presently i am working on Linux platform. The below code i have used for connecting to mysql Database.
why don't try like this...

Source code for just to make a connection.
Connection con = null;
try
{
Class.forName (driver name);//I am using "org.gjt.mm.mysql.Driver"
con = DriverManager.getConnection("jdbc:mysql://localhost/DBName"); I am giving "jdbc:mysql://localhost/SmartNet?user=root" my database name is SmartNet.
System.out.println("connected to DBName");
}
catch (SQLException e)
{
System.out.println("error "+e);
}
 
IntelliJ Java IDE
 
subject: JDBC_MySQL - Driver not possible to load
 
Threads others viewed
jdbc
No suitable driver
Unix Connection Sockets
BMP, Jboss, and mysql configuring
Cannot open connection issue
developer file tools