Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2002
    Posts
    4

    Question Unanswered: Cannot connect mysql by using JDBC?

    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").newInstan ce();
    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.

  2. #2
    Join Date
    Dec 2002
    Location
    BELGIUM
    Posts
    18
    Hi,

    can you post your stacktrace, as visible in the catch-clause ?

    try {
    // your database connectivity initialisation
    }
    catch(Throwable t) {
    t.printStackTrace(System.err);
    }

    regards,
    Benny Lootens
    Java Developer
    BELGIUM

  3. #3
    Join Date
    Dec 2002
    Posts
    4
    Hi,
    Thank Benny.
    Now i can create table in mysql.
    After i add the catch exception statement , it shows the error to me.(Syntax error).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •