Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / October 2004

Tip: Looking for answers? Try searching our database.

accessing mySQL database with Java

Thread view: 
Raphi - 28 Oct 2004 17:46 GMT
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:odbc: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(Unknown 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
David Harper - 29 Oct 2004 07:17 GMT
> void database() throws ClassNotFoundException, SQLException{
>         try{
[quoted text clipped - 6 lines]
>         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
Raphi - 29 Oct 2004 21:25 GMT
dude, thanks so much. ok, i'm gonna try this. :)

Raphi


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.