File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes JDBC help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "JDBC help" Watch "JDBC help" New topic

JDBC help

Jack Bolton
Ranch Hand

Joined: May 08, 2006
Posts: 65
i am using SQL Server 2000 Personal Edition.
and i'm accesing "the Northwind" database like this:
this is some part of the code:

but it always prints the error in the console. So the program it's not accesing the database.
What do i have to correct here?
[ July 02, 2006: Message edited by: Jack Bolton ]
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Here's some code that I'm pretty sure works. The Class.forName() technique should be just as good (or better) than the registerDriver() technique.

This looks pretty similar to your own. Can you show us the full stack trace?

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
marc weber

Joined: Aug 31, 2004
Posts: 11343

Moving to the JDBC forum.

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
Jack Bolton
Ranch Hand

Joined: May 08, 2006
Posts: 65
the getconnection should be like this?

because the result is the same as before.

here is the stack trace(what it prints on the console):

java.sql.SQLException: [Microsoft][Driver Manager ODBC]
The name of the data source cannot be found, and the default driver was not specified.

at sun.jdbc.odbc.JdbcOdbc.createSQLException(
at sun.jdbc.odbc.JdbcOdbc.standardError(
at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(
at sun.jdbc.odbc.JdbcOdbcConnection.initialize(
at sun.jdbc.odbc.JdbcOdbcDriver.connect(
at java.sql.DriverManager.getConnection(
at java.sql.DriverManager.getConnection(
at DBTest.<init>(
at DBTest.main(
[ July 03, 2006: Message edited by: Jack Bolton ]
Naseem Khan
Ranch Hand

Joined: Apr 25, 2005
Posts: 809
have you made Northwind user dsn?

use following code or one which Stan posted.


[ July 03, 2006: Message edited by: Naseem Khan ]
[ July 03, 2006: Message edited by: Naseem Khan ]

Asking Smart Questions FAQ - How To Put Your Code In Code Tags
I agree. Here's the link:
subject: JDBC help
jQuery in Action, 3rd edition