File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC help

 
Jack Bolton
Ranch Hand
Posts: 65
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8791
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to the JDBC forum.
 
Jack Bolton
Ranch Hand
Posts: 65
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 809
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic