Hi Michael, 

> -----Original Message-----
> From: Michael Bitzko [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, November 08, 2001 5:57 PM
> To: [EMAIL PROTECTED]
> Subject: Simple JDBC Question
> 
> 
>      Please forgive the simplicity of the question, but I'm having
> trouble reading between the lines regarding the JDBC interface.    I
> have the following simple code, which load the bridge driver, and then
> attempts to connect to the driver.  The system can't make the
> connection.  My question is the address section of the url.   Where
> would it be looking for a database "my-dsn", and if I have mySql located
> in the "C:" drive, what would the syntax appear like?
> 
> 
> Thanks for your help
> Mike Bitzko
> 
> 
> public static void initialize() {
>       String query = "SELECT * FROM emp";
>       String url   = "jdbc:odbc:my-dsn";
>       try {
>           // Load the jdbc-odbc bridge driver
>           Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
>           System.out.println(".. Loading of the system driver completed"
> );
>           DriverManager.setLogStream(System.out);
> 
>           // Attempt to connect to a driver.  Each one
>           // of the registered drivers will be loaded until
>           // one is found that can process this URL
> 
>           System.out.println(".. Attempt to connect to a driver" );
>           Connection con = DriverManager.getConnection (url, "my-user",
> "my-passwd");
>           System.out.println(".. Attempt to connect is successful" );
>           checkForWarning (con.getWarnings ());
> 
> 
> 
> 
> =======
> \jdk1.3.1_01\bin\javaw -classpath
> "D:\IntroitSys\untitled1\classes;E:\JBuilder4\lib\jbcl.jar;E:\JBuilde
> r4\lib\dx.jar;E:\JBuilder4\lib\beandt.jar;D:\jdk1.3.1_01\demo\jfc\Jav
> a2D\Java2Demo.jar;D:\jdk1.3.1_01\jre\lib\i18n.jar;D:\jdk1.3.1_01\jre\
> lib\jaws.jar;D:\jdk1.3.1_01\jre\lib\rt.jar;D:\jdk1.3.1_01\jre\lib\sun
> rsasign.jar;D:\jdk1.3.1_01\lib\dt.jar;D:\jdk1.3.1_01\lib\htmlconverte
> r.jar;D:\jdk1.3.1_01\lib\tools.jar"
> untitled1.Application1
> .. Loading of the system driver completed
> .. Attempt to connect to a driver
> DriverManager.getConnection("jdbc:odbc:my-dsn")
>     trying
> driver[className=sun.jdbc.odbc.JdbcOdbcDriver,sun.jdbc.odbc.JdbcOdbcD
> river@4a8cd1]
> 
> *Driver.connect (jdbc:odbc:my-dsn)
> JDBC to ODBC Bridge: Checking security
> No SecurityManager present, assuming trusted application/applet
> JDBC to ODBC Bridge 2.0001
> Current Date/Time: Thu Nov 08 17:46:05 PST 2001
> Loading JdbcOdbc library
> Allocating Environment handle (SQLAllocEnv)
> hEnv=166007376
> Allocating Connection handle (SQLAllocConnect)
> hDbc=166007544
> Connecting (SQLDriverConnect), hDbc=166007544,
> szConnStrIn=DSN=my-dsn;UID=my-user;PWD=my-passwd
> RETCODE = -1
> ERROR - Generating SQLException...
> Closing connection (SQLFreeConnect), hDbc=166007544
> Closing environment (SQLFreeEnv), hEnv=166007376
> getConnection failed: java.sql.SQLException: [Microsoft][ODBC Driver
> Manager] Data source name not found and no default driver specified
> 
> *** SQLException caught ***
> 
> SQLState: IM002
> Message:  [Microsoft][ODBC Driver Manager] Data source name not found
> and no default driver specified
> Vendor:
> 

The above error says, you didn't configured the MyODBC DSN 
'my-dsn'. When you are using JdbcOdbc Bridge driver inorder to 
access MySQL through JAVA applications through MyODBC driver, 
you need to define MyODBC DSN also. So, first define this, and 
then try connecting, and hopefully it will.

For more information about MyODBC, refer to its online 
manual at www.mysql.com/doc (section 8.3)

Regards, venu
-- 
For technical support contracts, go to https://order.mysql.com
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /  Mr. Venu <[EMAIL PROTECTED]>
 / /|_/ / // /\ \/ /_/ / /__ MySQL AB, Developer
/_/  /_/\_, /___/\___\_\___/ California, USA
       <___/ www.mysql.com



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to