This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Connecting to SQL server db over a LAN

 
Jyothsna Sri Y
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I wish to connect to a database existing on another machine on the LAN, given the server name, IP address, login and password for the db.How can I do it?
Thanks.
Cheers
Jyothsna.
 
Joe Ess
Bartender
Pie
Posts: 9265
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DriverManager.getConnection() takes a URL, user name and password as arguments. Check your JDBC driver documentation to see exactly how the URL is constructed. For example the JDBC-ODBC bridge starts with

[ September 25, 2003: Message edited by: Joe Ess ]
 
Joe Ess
Bartender
Pie
Posts: 9265
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Darn smilies. that should be jdbc, a colon, then odbc.
 
Jyothsna Sri Y
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Joe,
Thanks a ton for the immediate response. But it's urgent!!!
I wanted to know how to connect to a database which exists on another system named for example "WorkStation40" where the table name is "PQR" and the user name is "abc" and password "123". How am I supposed to frame the URL?
Where does it go in the general code of type:
String url = new String("jdbc dbc sn");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection(url,"abc","123");
Thanks.
cheers
Jyothsna.
 
Jyothsna Sri Y
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That was supposed to be jdbc followed by a colon followed by odbc, colon dsn.
Jyothsna
 
Rema Remulta
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
In case you haven't found the solution of the problem, this is how to do it:
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
con = DriverManager.getConnection("jdbc:microsoft:sqlserver://10.0.0.1:1669;DatabaseName=" + database + ";User=" + userID + ";Password=" + pwd + "");
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic