Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JDBC connection problem - can't establish a session  RSS feed

John Bushell
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.
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()
System.out.println("Testing JDBCTest...");
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 (
catch (ClassNotFoundException ce)
System.out.println("error : "+ce);
catch (java.sql.SQLException se)
System.out.println("error : "+se);
either way sincere regards,
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!