accessing mySQL database with Java

This is a discussion on accessing mySQL database with Java within the JDBC JAVA forums in Framework and Interface Programming category; Hello Finally i could get the jdbc driver to run, but the rest is still not running. i could successfully create a database and a table with the command line, but from the applet i wrote, i can't access it. here the code and then the error messagen: the name of the table is: esgeht. 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 dbc:esgeht"; Connection con = DriverManager.getConnection(url,"admin","admin"); } ok. ist gegaxt java.sql.SQLException: [Microsoft][ODBC Driver Manager] Der Datenquellenname wurde nicht gefunden, und es wurde kein Standardtreiber angegeben at ...

Go Back   Application Development Forum > Framework and Interface Programming > JDBC JAVA

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 10-28-2004, 12:46 PM
Raphi
Guest
 
Default accessing mySQL database with Java

Hello

Finally i could get the jdbc driver to run, but the rest is still not
running. i could successfully create a database and a table with the
command line, but from the applet i wrote, i can't access it. here the
code and then the error messagen:

the name of the table is: esgeht.

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 = "jdbcdbc:esgeht";
Connection con = DriverManager.getConnection(url,"admin","admin");
}

ok. ist gegaxt
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Der
Datenquellenname wurde nicht gefunden, und es wurde kein
Standardtreiber angegeben
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcConnection.initialize(Unknow n Source)
at sun.jdbc.odbc.JdbcOdbcDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at HelloWorld.database(HelloWorld.java:51)
at HelloWorld.start(HelloWorld.java:32)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)


any ideas what i could do???? while I'm asking... when i create the
database. is it possible to use there a different password for each
database??

raphi
Reply With Quote
  #2  
Old 10-29-2004, 02:17 AM
David Harper
Guest
 
Default Re: accessing mySQL database with Java

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 = "jdbcdbc: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

Reply With Quote
  #3  
Old 10-29-2004, 04:26 PM
Raphi
Guest
 
Default Re: accessing mySQL database with Java

dude, thanks so much. ok, i'm gonna try this.

Raphi
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 07:20 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.