Results 1 to 5 of 5

Thread: MySQL Driver ?

  1. #1
    Join Date
    Apr 2003
    Location
    Franc
    Posts
    3

    Unanswered: MySQL Driver ?

    In fact i must modify an existing java prorgam. I tried to do this with JBuilder 8. But i can't run the initial program.

    The problem is that he don't accept the lines:

    private final String MYSQLDRIVER = "org.gjt.mm.mysql.Driver";
    ...
    try
    {
    Class.forName(this.MYSQLDRIVER);
    ...

    If anyone can explain me want i must do, that would be fantastic

  2. #2
    Join Date
    Mar 2003
    Location
    Denmark
    Posts
    15
    Download it here:

    http://mmmysql.sourceforge.net/

    and add it to the classpath of JBuilder...


    /Carsten

  3. #3
    Join Date
    Apr 2003
    Location
    Franc
    Posts
    3
    Thanks!

    Now i have the problem that i can read the tables but i cannot write in:
    queries like this fail:
    String query = "INSERT INTO flexions VALUES(" +
    flexion.getKey() + "," +
    "\"" + flexion.getContent() + "\"," +
    "\"" + flexion.getType() + "\"," +
    "\"" + flexion.getCategory() + "\")";
    this.getStatement().executeQuery(query);

    java.sql.SQLException: Can not issue data manipulation statements with executeQuery()

    all queries of writing in the existing tables dont work but reading is no problem.
    I have installed the mysql 3.2!

  4. #4
    Join Date
    Mar 2003
    Location
    Denmark
    Posts
    15
    Taken from the Java API doc:
    executeQuery(String sql): Executes an SQL statement that returns a single ResultSet object.
    executeUpdate(String sql): Executes an SQL INSERT, UPDATE or DELETE statement.

    Also, I would recommend using PreparedStatement such that you would write:

    ...
    PreperedeStatement pstmt = con.prepareStatement("INSERT INTO flexion VALUES(?,?,?,?)";
    pstmt.setInt(1, flexion.getKey());
    pstmt.setString(2, flexion.getContent());
    pstmt.setString(3, flexion.getType());
    pstmt.setString(4, flexion.getCategory());
    pstmt.executeUpdate();

    // --- close up ---
    pstmt.close();
    con.close();

    /Carsten

  5. #5
    Join Date
    Apr 2003
    Location
    Franc
    Posts
    3
    Ok finally in works!

    Very Thanks, but i dont understand why the programm was written like this.
    On other computers the program works well. 2 people work with the program i should just make modifications but i got it not turning!

    Anyway! Now i can begin.

    John

Posting Permissions

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