aspose file tools
The moose likes JDBC and Relational Databases and the fly likes Establishing JDBC Connection Using Port Ips Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of RabbitMQ in Depth this week in the Open Source forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Establishing JDBC Connection Using Port Ips" Watch "Establishing JDBC Connection Using Port Ips" New topic
Author

Establishing JDBC Connection Using Port Ips

nivas khan
Greenhorn

Joined: Aug 08, 2001
Posts: 7
Sir,
i have a Ms SQL server DB on my desktop.
And i want to connect to it using the methods described below.
but i am unable to connect.Can u help me with the code..
I have a win NT OS.What is the Ip adress to be given.
Nivas

String dataPath = "jdbc dbc RIVER={SQL Server}:SERVER={ip_address}:?DATABASE=MY_DBASE";
where is the value of the port you want to use...like 1433 or something like that.
Use the user id and password like this:
Connection conn = DriverManagner.getConnection( dataPath, USER_NAME, my_pass);
DAYANAND BURAMSHETTY
Ranch Hand

Joined: Aug 06, 2001
Posts: 34

public Connection getConnection() throws SQLException
{
System.out.println("ConnectionTest....................\n");
try{
Class.forName("weblogic.jdbc.mssqlserver4.Driver").newInstance();
} catch (ClassNotFoundException cnfe) {
throw new SQLException(cnfe.getMessage());
} catch (IllegalAccessException iae) {
throw new SQLException(iae.getMessage());
} catch (InstantiationException ie) {
throw new SQLException(ie.getMessage());
}
Connection con = null;
Properties props = new Properties();
props.put("user","scott");
props.put("password","tiger");
try {
con = DriverManager.getConnection("jdbc:weblogic:mssqlserver4:MY_DBASE@ip_address:1433",props);
return con;
} catch (Exception e) {
System.out.println("Exception :::"+e.getMessage());
throw new SQLException (e.getMessage());
}
}


Dil se....,<BR>Dayanand<BR>0065-8839071(off)<BR>0065-7547034(Res0
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Establishing JDBC Connection Using Port Ips