This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes JDBC 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 EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC help" Watch "JDBC help" New topic
Author

JDBC help

Jack Bolton
Ranch Hand

Joined: May 08, 2006
Posts: 65
Hi,
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
Sheriff

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
sscce.org
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(JdbcOdbc.java:6958)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7115)
at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:3074)
at sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOdbcConnection.java:3
23)
at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:174)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:193)
at DBTest.<init>(DBTest.java:15)
at DBTest.main(DBTest.java:35)
[ 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.




Naseem

[ 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: http://aspose.com/file-tools
 
subject: JDBC help
 
Similar Threads
accesing a database
accesing data from an IP address
Issue w/ accesing file from a Servlet
Accesing database on a PC in Network
accesing database???