Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

connection to local database using ip address

 
Dinesh Sharma
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am using Sun's JdbcOdbcDriver. I want to connect
to a ODBC datasource on the same computer through the
hostname or the IP address.
The following is what i tried (ibm is hostname, sample is the ODBC datasource) but the program throws SQLexception. Can someone help me?
***********************************
//String url = "jdbc dbc:/ibm/sample"; --> not working
//String url = "jdbc dbc:/ibm:1234/sample"; --> not working
//String url = "jdbc dbc://ibm/sample"; --> not working
//String url = "jdbc dbc:ibm/sample"; --> not working
//String url = "jdbc dbc:127.0.0.1/sample"; --> not working
.....
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
Connection con = DriverManager.getConnection(url, "dino", "password");
Statement stmt = con.createStatement();
}
...
***********************************
thanx
[This message has been edited by Thomas Paul (edited November 27, 2000).]
 
KASI VISHWANATH
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
U have to create a dsn name in this context not an ip address as in the case of jdbc type two driver
------------------
I.K.VISHWANATH
 
subbu smile
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

There is no necessary to mention the IP address when we go for JDBC-ODBC bridge type of connection.
In my opinion for such a type of connection we can write a simple program like this,
con = DriverManager.getConnection("jdbc dbc:dsn","sa","");
Statement st= con.createStatement();
------
----


[This message has been edited by Thomas Paul (edited November 27, 2000).]
 
Dinesh Sharma
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I know the syntax is jdbcdbc:[datasourcename]
for a local database. But what i really wanted to
know was how will connect to a remote machine's datasource in a network using
a hostname or a IP address.

 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to specify that information when you define the ODBC source.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic