Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC connection problem - can't establish a session

 
John Bushell
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to connect to the eRespond database for the purpose of the customer connectivity project (data cleansing java program/script), but I keep getting the following exception :
error : java.sql.SQLException: [OraDriver] Connection refused from server. Please check if the Oracle service 'pdstest.johnb' is running.
<(DESCRIPTION=(TMP=)(USNNUM=150999040)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))>
I have made a few checks to ensure I am not overlooking anything simple :
- The user I am connecting as has been checked for validity/connectivity via TOAD and a 'SQLPLUS worksheet' session and is OK
- tnsping is OK for the database service name (pdstest.johnb) I am using in the jdbc connection url string
- I can ping the database server OK from my machine
- I get the same error message when trying to connect to other databases
- The client JDBC driver I am using is 8-9i compliant and is a type 4.
- I am using JDK 2 (1.4.1) and the JDBC 3.0 i-net ORANXO type 4 driver
- The CLASSPATH includes the relevant JDBC package
The code I am using is as follows :
==========================================
import java.sql.*;
import javax.sql.*;
import com.inet.ora.*;
class JDBCTest
{
public static void main(String args[])
{
JDBCTest jbbcTest = new JDBCTest();
}

public JDBCTest()
{
try
{
System.out.println("Testing JDBCTest...");
Class.forName("com.inet.ora.OraDriver");
Connection con = DriverManager.getConnection("jdbc:inetora istdev1:1521 dstest.johnb","johnb","johnb");
String query = "select * from john";
Statement state = con.createStatement();
ResultSet rs = state.executeQuery(query);

while (rs.next())
{
System.out.println(
rs.getString(1)+"\t"+
rs.getString(2)+"\t"+
rs.getString(3));
}
}
catch (ClassNotFoundException ce)
{
System.out.println("error : "+ce);
}
catch (java.sql.SQLException se)
{
System.out.println("error : "+se);
}
}
}
==========================================
either way sincere regards,
John
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic