Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Connection string issues to SQL Server

843859Jun 26 2007 — edited Jul 5 2007
Hey guys, I've been using these forums as a great reference for awhile and now I'm stumped and in need of a hand.

So I'm writing a web app and need to connect to a SQL Server db, here is what I've created from the Java side of things:
			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
			System.out.println("Class found");
			String accessDBURLPrefix = "jdbc:odbc:sqlserver://142.225.235.83;Initial Catalog=event;Persist Security Info=True;User ID=******";			
			Connection con = DriverManager.getConnection(accessDBURLPrefix);
			System.out.println("Database Found");
			Statement s = con.createStatement();
			//String query = "SELECT * FROM [SITE SETUP]";
			ResultSet rs = s.executeQuery(query);
I'm getting the error:
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
Now I can open the db no problem in the VS 2005 connection manager and the connection string it lists in the properties is:
Data Source=142.174.35.83;Initial Catalog=event;Persist Security Info=True;User ID=*******
I guess even after looking up all the connection string examples online I still can't get it right.

Any hints?

Message was edited by:
Piers
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 2 2007
Added on Jun 26 2007
13 comments
706 views