aspose file tools*
The moose likes JDBC and the fly likes need help with connect to driver Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "need help with connect to driver" Watch "need help with connect to driver" New topic
Author

need help with connect to driver

eric lee
Ranch Hand

Joined: Nov 04, 2002
Posts: 86
When i run "java Auth", it shows data source name
not found.so how can i connect to jdbc driver?
Thanks.
------------------------------------------------
import java.sql.*;
public class Auth
{
public static void main(String args[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch (java.lang.ClassNotFoundException e)
{
System.out.println(e.getMessage());
}
try
{
Connection con =
DriverManager.getConnection("jdbc dbc:bookbase");
Statement stmt = con.createStatement();
stmt.executeUpdate("create table authTab (" +
"auth char(10), " +
"tel char(12) CONSTRAINT authIndex PRIMARY KEY)");
stmt.close();
con.close();
}
catch (SQLException ex)
{
System.out.println("SQLException: "+ex.getMessage());
}
}
}
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1135

Hi Eric,
Excuse me if you are already aware of this, but you need to set up an ODBC data source.
[I am assuming -- from your post -- that your platform is Windows and you are using some kind of Microsoft database -- like MS Access.]
If this is correct, then you set up the data source via "Control Panel".
On my Windows XP machine, when I open the "Control Panel" window, it contains an icon entitled "Administrative Tools". When I double-click on that icon, I get another window that contains an icon entitled "Data Sources (ODBC)". Double-clicking on that icon starts up a "wizard" that guides you through setting up a data source.
Hope this helps.
Good Luck,
Avi.
eric lee
Ranch Hand

Joined: Nov 04, 2002
Posts: 86
Hi Avi:
my computer is Win 2000. when i clik Microsoft
odbc administrator, i did not see any "wizard"
my odbc just has "User DNS","System DNS",
"File DNS","Driver",....something like this.
so how can i set up? Thanks
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1135

Eric,
I think you need to set up a "User DNS". It's been a long time since I did it, so I don't remember exactly, but I do remember I managed to figure it out by myself (and I'm too lazy to make the effort to hold your hand and guide you through it -- sorry). Try reading the "help", or doing an Internet search for "setting up ODBC datasource on Windows 2000 as User DSN" (or something like that :-)
Good Luck,
Avi.
P.S. I _know_ you can do it, Eric!
eric lee
Ranch Hand

Joined: Nov 04, 2002
Posts: 86
Thanks Avi Abrami , i will try that
Waqas Ahmed Siddiqui
Greenhorn

Joined: Feb 08, 2003
Posts: 4
Hi,
Maybe i can help you if you are still stucked.
1. Go to system dns.
2. choose add.
3. in the data source name , write the name you use for your db when u connect it.
4. choose your db from select.


Can u Help Me???
 
Consider Paul's rocket mass heater.
 
subject: need help with connect to driver