The Artima Developer Community
Sponsored Link

Java Answers Forum
JDBC-ODBC Bridge

4 replies on 1 page. Most recent reply: Feb 7, 2003 11:22 AM by Branko

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 4 replies on 1 page
Branko

Posts: 9
Nickname: orbusian
Registered: Feb, 2003

JDBC-ODBC Bridge Posted: Feb 5, 2003 2:57 PM
Reply to this message Reply
Advertisement
What's wrong with this code:

import java.sql.*;

public class Bra {
public static void main(String args[]) {
String url = "jdbc:odbc:myDataBase";
Connection con;
String createString;
createString = "create table COFFEES " +
"(COF_NAME VARCHAR(32), " +
"SUP_ID INTEGER, " +
"PRICE FLOAT, " +
"SALES INTEGER, " +
"TOTAL INTEGER)";
Statement stmt;

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

try {
con = DriverManager.getConnection(url, " ", " ");
stmt = con.createStatement();
stmt.executeUpdate(createString);
stmt.close();
con.close();

} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
}
}

In runtime I get this message:

SQLException: [Microsoft][ODBC Driver Manager] Data source
name not found and no default driver specified


I have J2SE 1.4.1 Installed, and I have an empty
Microsoft access database in the project folder named myDataBase.

I do not have downloaded any additional driver to make connection with the database.

Is this driver (sun.jdbc.odbc.JdbcOdbcDriver) included
with the J2SE, or do I need to make some configuration.


Rob

Posts: 2
Nickname: robf
Registered: Jan, 2003

Re: JDBC-ODBC Bridge Posted: Feb 6, 2003 3:25 PM
Reply to this message Reply
Branko,

You need to setup a DSN(Data Source Name) using the Data Sources (ODBC) admin tool. After that you need to modify your url, "jdbc:odbc:<<your DSN>>".

Branko

Posts: 9
Nickname: orbusian
Registered: Feb, 2003

Re: JDBC-ODBC Bridge Posted: Feb 6, 2003 5:16 PM
Reply to this message Reply
> Branko,
>
> You need to setup a DSN(Data Source Name) using the Data
> Sources (ODBC) admin tool. After that you need to modify
> your url, "jdbc:odbc:<<your DSN>>".

Would you be so kind to explain me, how can I make
this setup, because I haven't used yet this admin tool
and I don't even know where to look for.

This task is very easy, by means of Visual
Studio.Net but in JAVA I steel can't get conected.

Rob

Posts: 2
Nickname: robf
Registered: Jan, 2003

Re: JDBC-ODBC Bridge Posted: Feb 7, 2003 8:38 AM
Reply to this message Reply
Branko,

I don't know what OS you are running, so I will assume that you are on a Windows platform like myself. I am running Windows 2000. To get to the Data Sources (ODBC) Admin Tool, you need to do the following: Start -> Settings -> Control Panel -> Administrative Tools -> Data Sources (ODBC). This will launch the Microsoft ODBC Administrator console, which is the tool that I referenced in my initial post. Once the app loads you will see several tabs across the top, three of which have 'DSN' in the name. These are the tabs that are used to configure different types of DSNs: User, System and File. Actually configuring a DSN is a very straight forward process.

Once the DSN has been configured the name that you give it will be used in the url, "jdbc:odbc:<< you DSN>>".

I hope this helps.

Rob

Branko

Posts: 9
Nickname: orbusian
Registered: Feb, 2003

Re: JDBC-ODBC Bridge Posted: Feb 7, 2003 11:22 AM
Reply to this message Reply
Finaly SUCCESS !!!

Thank You, thank you very much indeed !
I have finaly got connected !

Flat View: This topic has 4 replies on 1 page
Topic: Printer's Use Previous Topic   Next Topic Topic: Looking for com.sun.image.codec.jpeg package

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use