• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Connecting to SQL server db over a LAN

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That was supposed to be jdbc followed by a colon followed by odbc, colon dsn.
Jyothsna
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 + "");
 
Goodbye moon men. Hello tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic