Re: accessing mySQL database with Java
From: David Harper (devnull_at_obliquity.u-net.com)
Date: 10/29/04
- Previous message: Raphi: "accessing mySQL database with Java"
- In reply to: Raphi: "accessing mySQL database with Java"
- Next in thread: Raphi: "Re: accessing mySQL database with Java"
- Reply: Raphi: "Re: accessing mySQL database with Java"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: Raphi: "accessing mySQL database with Java"
- In reply to: Raphi: "accessing mySQL database with Java"
- Next in thread: Raphi: "Re: accessing mySQL database with Java"
- Reply: Raphi: "Re: accessing mySQL database with Java"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|