Re: accessing mySQL database with Java

From: David Harper (devnull_at_obliquity.u-net.com)
Date: 10/29/04

  • Next message: Raphi: "Re: accessing mySQL database with Java"
    Date: Fri, 29 Oct 2004 06:17:14 GMT
    
    

    Raphi wrote:
    > void database() throws ClassNotFoundException, SQLException{
    > try{
    > Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    > System.out.println("ok. ist gegaxt");
    > } catch(ClassNotFoundException e){
    > System.out.println("nicht gegangen");
    > }
    >
    > String url = "jdbc:odbc:esgeht";
    > Connection con = DriverManager.getConnection(url,"admin","admin");

    You're loading the ODBC driver and attempting to connect to an
    ODBC-style database URL, yet your subject line says that you're trying
    to access a MySQL database.

    This is rather like expecting a knowledge of Norwegian to come in handy
    when you visit China. It isn't going to work, because MySQL and ODBC
    database servers have different underlying protocols. The ODBC driver
    knows the ODBC protocol, and the MySQL driver knows the MySQL protocol.

    You need to use the MySQL driver and a MySQL-style URL to connect to a
    MySQL database.

    Download the MySQL JDBC driver from the MySQL web site, read the
    documentation that comes with it, then alter your program to use the
    correct driver and URL. Make sure the MySQL driver JAR file is in your
    classpath, and run your program again.

    Hope this helps.

    David Harper
    Cambridge, England


  • Next message: Raphi: "Re: accessing mySQL database with Java"

    Relevant Pages

    • Re: resultset is an iterator?
      ... >> done by the JDBC driver and the database backend. ... >> drag it all into memory but I have noticed that MySQL seems to do this. ... ResultSets are completely retrieved and stored in memory. ...
      (comp.lang.java.databases)
    • Re: MySQL JDBC driver - implications for non-GPLed apps
      ... >> driver a particular user wants to implement. ... MySQL AB does not purport to be our ... > care to provide a clear-cut explanation as part of their license agreement. ... >> However then you look at it, is the value of the driver and database ...
      (comp.lang.java.databases)
    • Re: mySQL Connection String
      ... >>I use mySQL but can connect. ... >You say you can't connect to a MySQL database using the ODBC driver ... ODBC Driver for MySQL ...
      (microsoft.public.inetserver.asp.db)
    • Re: Project 2000 to mySQL Database
      ... I recall people having trouble with the Oracle ODBC driver and having to use ... It would not be surprising to see that the mySQL driver does not work ... > ODBC database should work. ... >>> of SQL Server I should obtain? ...
      (microsoft.public.project.vba)
    • Re: MySQL JDBC driver - implications for non-GPLed apps
      ... > closed-sourced application that makes use of the GPLed MySQL JDBC driver? ... > another database by using its driver makes the entire application a "derived ... this is what the GPL clause seems to ...
      (comp.lang.java.databases)