• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

JDBC help

 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to the JDBC forum.
 
Jack Bolton
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 809
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic