aspose file tools*
The moose likes JDBC and the fly likes jdbc:odbc DSN less connection for SQL Server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "jdbc:odbc DSN less connection for SQL Server" Watch "jdbc:odbc DSN less connection for SQL Server" New topic
Author

jdbc:odbc DSN less connection for SQL Server

asnarun
Greenhorn

Joined: Oct 03, 2001
Posts: 3
Hi,
I'm having trouble getting a DSN less connection for MS SQL Server. I went through some of the topics in this forum but could not get the result.
Here is my code:
try
{
// Load the driver class
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

// Open the connection to the database
dbCon = DriverManager.getConnection("jdbc odbc:;DRIVER={SQL Server};SERVER=SQLDEV2;DATABASE=masprjd2", "mas", "mas");
}catch(ClassNotFoundException ce)
{
ce.printStackTrace();
}catch(SQLException sqe)
{
sqe.printStackTrace();
}
My server is SQLDEV2 and the database name is masprjd2. While running the above code I get the following error:
java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(DriverManager.java:537)
at java.sql.DriverManager.getConnection(DriverManager.java:177)
at AQCore.MACSSInputHandler.doConnect(MACSSInputHandler.java:457)
at AQCore.MACSSInputHandler.<init>(MACSSInputHandler.java:100)
at AQCore.MACSSInputHandler.main(MACSSInputHandler.java:857)

I'm working on jdk1.3 version. I've been struggling with this for quite a while and could not overcome the error. Please help me out.
Thanks
Arun
Yogen Vadnere
Ranch Hand

Joined: Sep 20, 2001
Posts: 58
Your error says everything..
why dont u try another driver..possibly type IV.

Yogen Vadnere
asnarun
Greenhorn

Joined: Oct 03, 2001
Posts: 3
Well I was successful in running the above code with slight change in the connection string.
I had type as "jdbc odbc:;DRIVER={SQL Server};SERVER=SQLDEV2;DATABASE=masprjd2
I changed it to "jdbcdbcRIVER={SQL Server};SERVER=SQLDEV2;DATABASE=masprjd2
It worked fine.
Tim Glass
Greenhorn

Joined: Oct 29, 2000
Posts: 17
I tried a similar piece of code I found on Javaranch for a DNS-less connection to an access data base:
conn = DriverManager.getConnection("jdbc dbc RIVER=Microsoft Access Driver (*.mdb);DBQ=c:/java/companytime/CTData.mdb");
The code compiles fine, and when I run the program no exceptions are thrown. But I do get this message via command line:
"[Microsoft][ODBC SQL Server Driver]Optional feature not implemented"
I tried registering the database with my DNS in Windows and tried the generice connection, but got the same message. Any ideas?
Thanks,
Tim
asnarun
Greenhorn

Joined: Oct 03, 2001
Posts: 3
Hi Tim,
I read from a microsoft site saying that error message comes when you to try to update SQL Server 7.0 Unicode Datatypes from MS Access.
The url to that site: http://support.microsoft.com/support/kb/articles/Q222/1/04.asp
Hope this helps you
Thanks
Arun
Tim Glass
Greenhorn

Joined: Oct 29, 2000
Posts: 17
Thanks, Arun. At least now I know it's not my code. However the knowledgebase article references SQL 7 and Access 97. I'm trying to connect to an Access 2000 database so I'm not sure it applies. As of this writing I'm downloading the Jet4.0 Service pack for Windows 2000 to see if that rectifies the situation.
Thanks again for the lead.
Tim
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jdbc:odbc DSN less connection for SQL Server