Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes JDBC and Relational Databases and the fly likes how to connect with mssql Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "how to connect with mssql" Watch "how to connect with mssql" New topic

how to connect with mssql

ray bond
Ranch Hand

Joined: Oct 11, 2000
Posts: 111
hello there ,
I have serverlet jdbc application , which communicates with mysql database , now I have to use mssql instead of mysql , my servelets will be on "serverapplication" and mssql database is running on
"serversql" , it means to entirely different pysical server systems ,
before that mysql and servlets were on same server "serverapplication" , and below is how i did,
-- Class.forName("");
-- DriverManager.getConnection("jdbc:mysql://localhost/mydb");
now can anybody guide me that how can i access mssql database which is on different server , and what should i write ,
for "Class.forName(...." and for "DriverMgr.getCon(....",
waiting for urgent reply
David Freels
Ranch Hand

Joined: Feb 01, 2001
Posts: 102
For Windows use this:
-- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
-- DriverManager.getConnection("jdbc dbc SNNAME");
Where DSNNAME equals the DSN set up to connect to the SQL Server.
For non windows, go to and take a look at the commercial drivers available.
Sun Certified Programmer for the Java2 Platform
ray bond
Ranch Hand

Joined: Oct 11, 2000
Posts: 111
thanks for your reply , its working now.
I agree. Here's the link:
subject: how to connect with mssql
It's not a secret anymore!