Home » Open Source » Programming Interfaces » JDBC Connection problem on Windows 2008 R2
JDBC Connection problem on Windows 2008 R2 [message #548022] Mon, 19 March 2012 11:33 Go to next message
Messages: 1
Registered: March 2012
Junior Member
Hi ,

i'm having problems to connect to any DB (Oracle/ SQLServer) with java 7 from windows server 2008 R2.
below is my test code which when im running from my PC it's connecting but if i run it on the server it throws an exception.

i even tried to stop the firewall and again the same thing happens.
tnsping and sqlldr works fine only connection through jdbc fails.

do anyone have any idea for this issue??

Exception in thread "main" java.sql.SQLException: ☻
at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)

public class OracleDS {

     * @param args the command line arguments
    public static void oracleConnection() throws SQLException {
        OracleDataSource ods = new OracleDataSource();


        Connection conn = ods.getConnection();

        System.out.println("Oracle Connected");

    public static void sqlServerConnection() throws SQLException {
        SQLServerDataSource ss = new SQLServerDataSource();



        Connection conn = ss.getConnection();

        System.out.println("SqlServer Connected");

    public static void main(String[] args) throws SQLException {

Re: JDBC Connection problem on Windows 2008 R2 [message #548024 is a reply to message #548022] Mon, 19 March 2012 12:24 Go to previous messageGo to next message
Michel Cadot
Messages: 68597
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
This an Oracle forum.
You should post your question in a Microsoft forum.

Re: JDBC Connection problem on Windows 2008 R2 [message #548026 is a reply to message #548024] Mon, 19 March 2012 12:48 Go to previous message
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
bcm@bcm-laptop:~$ cat Conn.java
import java.sql.*;
class Conn {
  public static void main (String[] args) throws Exception
   Class.forName ("oracle.jdbc.OracleDriver");

   Connection conn = DriverManager.getConnection
     ("jdbc:oracle:thin:@//localhost:1521/v112", "scott", "tiger");
                        // @//machineName:port/SID,   userid,  password
   try {
     Statement stmt = conn.createStatement();
     try {
       ResultSet rset = stmt.executeQuery("select BANNER from SYS.V_$VERSION");
       try {
         while (rset.next())
           System.out.println (rset.getString(1));   // Print col 1
       finally {
          try { rset.close(); } catch (Exception ignore) {}
     finally {
       try { stmt.close(); } catch (Exception ignore) {}
   finally {
     try { conn.close(); } catch (Exception ignore) {}
bcm@bcm-laptop:~$ javac Conn.java
bcm@bcm-laptop:~$ export CLASSPATH=/u01/app/oracle/product/11.2.0/dbhome_1/owb/wf/lib/ojdbc14.jar:.
bcm@bcm-laptop:~$ java Conn
Oracle Database 11g Enterprise Edition Release - 64bit Production
PL/SQL Release - Production
CORE	Production
TNS for Linux: Version - Production
NLSRTL Version - Production
Previous Topic: Need help VERY BADLY
Next Topic: Reg sending mail with attachment with perl script
Goto Forum:

Current Time: Fri Feb 23 21:01:49 CST 2024