GeeCON Prague 2014*
The moose likes JDBC and the fly likes need help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Bookmark "need help" Watch "need help" New topic
Author

need help

priya agg
Greenhorn

Joined: Jun 24, 2008
Posts: 3
hello
i m new user working on java.i m getting problem while simply connecting with database.i m using sqlserver n java version-jdk1.5.0_04.
getting error----
java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at a.main(a.java:24)
while i m loading n establishing connection using system DSN
// load driver and prepare to access
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection con = DriverManager.getConnection(DSN,userid,password);
Statement stmt = con.createStatement();

plzzz help me to get things done
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

What URL are you using in your getConnection method?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
priya agg
Greenhorn

Joined: Jun 24, 2008
Posts: 3
Originally posted by Paul Sturrock:
What URL are you using in your getConnection method?


thanxs for an early reply

actually want to connect using DSN

Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection con = DriverManager.getConnection("jdbcdbc:"+DSN,USERID,PASSWORD);
Statement stmt = con.createStatement();

path are set.while running it shows error as specified earlier
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Why do you want to use JDBC-ODBC? There is no reason to use JDBC-ODBC with SQL Server. If you absolutely must do that, you will need to use the JDBC-ODBC bridge, not the SQL Server driver.
priya agg
Greenhorn

Joined: Jun 24, 2008
Posts: 3
please let me know more abt it...
please also want to know difference between both?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Have a read through our JDBC FAQs, they should answer your questions. You might also have a look at Sun's JDBC Tutorial.
[ June 24, 2008: Message edited by: Paul Sturrock ]
 
 
subject: need help