How to connect mySQL by using JDBC? [message #91639] |
Sat, 21 December 2002 22:49 |
stupid student
Messages: 1 Registered: December 2002
|
Junior Member |
|
|
Hi,
i cannot connect to the database(mysql) by using JDBC.
I hava set the classpath as
/usr/local/jakarta-tomcat-4.1.12/common/lib/mysql-connector-java-2.0.14
Inside my java program i wrote these statement to
make a connection to the database:
import java.sql.*;
public class CreateTable{
public static void main (String args[[]]) {
Connection con=null;
try{
Class.forName("org.git.mm.mysql.Driver").newInstance();
System.out.println("JDBC driver loaded");
con=DriverManager.getConnection("jdbc:mysql://localhost/test");
......
It give me a CreateTable.class after compile
But it cannot create any table on the database.
Is my setting wrong?
How can i connect to the database properly?
Thank you very much.
|
|
|
|
|