Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jdbc:odbc DSN less connection for SQL Server

 
asnarun
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your error says everything..
why dont u try another driver..possibly type IV.
 
asnarun
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic