Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4307662

DriverManager.getConnection fails if SecurityManager is set

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P3 P3
    • None
    • 1.3.0
    • core-libs



      Name: krT82822 Date: 01/27/2000


      1/27/2000 eval1127@eng -- (see also 4242716->4050006)

      Am filing a new bug re. this only because of the gap created by the "use a newer driver" disposition of bug # 4050006
      (which 4242716 was duped to) and the fact that using a really new ODBC driver at this point actually _breaks_ things.

      Specifically, several ODBC 3.x drivers do not work with the Bridge as of kestrel-beta. They are claimed to work with the
      FINAL kestrel, but there is no way for a user to verify this at this point.

      This bug is being filed as a reference bug against which we should definitely say whether the problem will be elininated
      in the final kestrel release (including when used with recent ODBC 3.x drivers)

      -----------------------------

      java version "1.3beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3beta-O)
      Java(TM) HotSpot Client VM (build 1.3beta-O, mixed mode)

      1/27/2000 eval1127@eng -- please see "Comments" section in new bug report

      DriverManager.getConnection returns with "No suitable driver"
      if RMISecurityManager is set. (in 1.2.2 all works fine)

      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
      Add
      "grant {
          permission java.sql.SQLPermission "setLog";
         }"
      to your java.policy or .java.policy File before start this Test Programm
      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

      Source Code:
      ====================================================================
      import java.sql.*;
      import java.io.*;
      import java.rmi.*;

      public class OdbcTest {
        private static String drv_s = "sun.jdbc.odbc.JdbcOdbcDriver";
        private static String cString = "jdbc:odbc:pap_db";

        public OdbcTest() {}

        public static void main(String[] args) {
          OdbcTest odbcTest = new OdbcTest();
          odbcTest.invokedStandalone = true;
          try {
            //!!!!!!!!!!!!!!!!
            System.setSecurityManager(new RMISecurityManager());
            //!!!!!!!!!!!!!!!!
            Class.forName(drv_s);
            DriverManager.setLogWriter(new PrintWriter(System.out));
            DriverManager.setLogStream(System.out);
            Connection newConn = DriverManager.getConnection(cString);
          } catch (Exception e) {
            e.printStackTrace();
          }
        }
        
        private boolean invokedStandalone = false;
      }
      ==========================================================================

      Output:
      ==========================================================================
      DriverManager.getConnection("jdbc:odbc:pap_db")
          trying driver[className=sun.jdbc.odbc.JdbcOdbcDriver,sun.jdbc.odbc.JdbcOdbc
      river@2dd2dd]
      *Driver.connect (jdbc:odbc:pap_db)
      JDBC to ODBC Bridge: Checking security
      JDBC to ODBC Bridge 1.2001
      Current Date/Time: Thu Jan 27 10:18:51 GMT+01:00 2000
      Loading JdbcOdbc library
      Unable to load JdbcOdbc library
      Unable to allocate environment
      getConnection: no suitable driver
      java.sql.SQLException: No suitable driver
              at java.sql.DriverManager.getConnection(Unknown Source)
              at java.sql.DriverManager.getConnection(Unknown Source)
              at SchufaTest.OdbcTest.main(OdbcTest.java:23)
      SQLException: SQLState(08001)
      java.sql.SQLException: No suitable driver
              at java.sql.DriverManager.getConnection(Unknown Source)
              at java.sql.DriverManager.getConnection(Unknown Source)
              at SchufaTest.OdbcTest.main(OdbcTest.java:23)
      ==============================================================================


      Output without "System.setSecurityManager(new RMISecurityManager());" (see
      Source Code)
      ==============================================================================
      DriverManager.getConnection("jdbc:odbc:pap_db")
          trying driver[className=sun.jdbc.odbc.JdbcOdbcDriver,sun.jdbc.odbc.JdbcOdbcD
      river@50169]
      *Driver.connect (jdbc:odbc:pap_db)
      JDBC to ODBC Bridge: Checking security
      No SecurityManager present, assuming trusted application/applet
      JDBC to ODBC Bridge 1.2001
      Current Date/Time: Thu Jan 27 10:23:34 GMT+01:00 2000
      Loading JdbcOdbc library
      Allocating Environment handle (SQLAllocEnv)
      hEnv=153555368
      Allocating Connection handle (SQLAllocConnect)
      hDbc=153555536
      Connecting (SQLDriverConnect), hDbc=153555536, szConnStrIn=DSN=pap_db;UID=null;P
      WD=null
      *Connection.getMetaData
      *DatabaseMetaData.getDriverName
      Get connection info string (SQLGetInfo), hDbc=153555536, fInfoType=6, len=300
      odbcjt32.dll
      Driver name: JDBC-ODBC Bridge (odbcjt32.dll)
      *DatabaseMetaData.getDriverVersion
      Get connection info string (SQLGetInfo), hDbc=153555536, fInfoType=7, len=300
      04.00.4202
      Driver version: 1.2001 (04.00.4202)
      Caching SQL type information
      *Connection.getMetaData
      *DatabaseMetaData.getTypeInfo
      Allocating Statement Handle (SQLAllocStmt), hDbc=153555536
      hStmt=153558576
      Get type info (SQLGetTypeInfo), hStmt=153558576, fSqlType=0
      Number of result columns (SQLNumResultCols), hStmt=153558576
      value=19
      Get connection info string (SQLGetInfo), hDbc=153555536, fInfoType=10, len=300
      03.51.0000
      Fetching (SQLFetch), hStmt=153558576
      Column attributes (SQLColAttributes), hStmt=153558576, icol=1, type=2
      value (int)=12
      Column attributes (SQLColAttributes), hStmt=153558576, icol=1, type=3
      value (int)=128
      Get string data (SQLGetData), hStmt=153558576, column=1, maxLen=129
      GUID
      Get integer data (SQLGetData), hStmt=153558576, column=2
      value=-11
      Get integer data (SQLGetData), hStmt=153558576, column=3
      value=36
      Fetching (SQLFetch), hStmt=153558576
      Get string data (SQLGetData), hStmt=153558576, column=1, maxLen=129
      BIT
      Get integer data (SQLGetData), hStmt=153558576, column=2
      value=-7
      Get integer data (SQLGetData), hStmt=153558576, column=3
      value=1
      Fetching (SQLFetch), hStmt=153558576
      Get string data (SQLGetData), hStmt=153558576, column=1, maxLen=129
      BYTE
      Get integer data (SQLGetData), hStmt=153558576, column=2
      value=-6
      Get integer data (SQLGetData), hStmt=153558576, column=3
      value=3
      Fetching (SQLFetch), hStmt=153558576
      Get string data (SQLGetData), hStmt=153558576, column=1, maxLen=129
      LONGBINARY
      Get integer data (SQLGetData), hStmt=153558576, column=2
      value=-4
      Get integer data (SQLGetData), hStmt=153558576, column=3
      value=1073741823
      Fetching (SQLFetch), hStmt=153558576
      Get string data (SQLGetData), hStmt=153558576, column=1, maxLen=129
      VARBINARY
      Get integer data (SQLGetData), hStmt=153558576, column=2
      value=-3
      Get integer data (SQLGetData), hStmt=153558576, column=3
      value=255
      Fetching (SQLFetch), hStmt=153558576
      Get string data (SQLGetData), hStmt=153558576, column=1, maxLen=129
      BINARY
      Get integer data (SQLGetData), hStmt=153558576, column=2
      value=-2
      Get integer data (SQLGetData), hStmt=153558576, column=3
      value=255
      Fetching (SQLFetch), hStmt=153558576
      Get string data (SQLGetData), hStmt=153558576, column=1, maxLen=129
      LONGCHAR
      Get integer data (SQLGetData), hStmt=153558576, column=2
      value=-1
      Get integer data (SQLGetData), hStmt=153558576, column=3
      value=2147483647
      Fetching (SQLFetch), hStmt=153558576
      Get string data (SQLGetData), hStmt=153558576, column=1, maxLen=129
      CHAR
      Get integer data (SQLGetData), hStmt=153558576, column=2
      value=1
      Get integer data (SQLGetData), hStmt=153558576, column=3
      value=255
      Fetching (SQLFetch), hStmt=153558576
      Get string data (SQLGetData), hStmt=153558576, column=1, maxLen=129
      CURRENCY
      Get integer data (SQLGetData), hStmt=153558576, column=2
      value=2
      Get integer data (SQLGetData), hStmt=153558576, column=3
      value=19
      Fetching (SQLFetch), hStmt=153558576
      Get string data (SQLGetData), hStmt=153558576, column=1, maxLen=129
      INTEGER
      Get integer data (SQLGetData), hStmt=153558576, column=2
      value=4
      Get integer data (SQLGetData), hStmt=153558576, column=3
      value=10
      Fetching (SQLFetch), hStmt=153558576
      Get string data (SQLGetData), hStmt=153558576, column=1, maxLen=129
      COUNTER
      Get integer data (SQLGetData), hStmt=153558576, column=2
      value=4
      Fetching (SQLFetch), hStmt=153558576
      Get string data (SQLGetData), hStmt=153558576, column=1, maxLen=129
      SMALLINT
      Get integer data (SQLGetData), hStmt=153558576, column=2
      value=5
      Get integer data (SQLGetData), hStmt=153558576, column=3
      value=5
      Fetching (SQLFetch), hStmt=153558576
      Get string data (SQLGetData), hStmt=153558576, column=1, maxLen=129
      REAL
      Get integer data (SQLGetData), hStmt=153558576, column=2
      value=7
      Get integer data (SQLGetData), hStmt=153558576, column=3
      value=7
      Fetching (SQLFetch), hStmt=153558576
      Get string data (SQLGetData), hStmt=153558576, column=1, maxLen=129
      DOUBLE
      Get integer data (SQLGetData), hStmt=153558576, column=2
      value=8
      Get integer data (SQLGetData), hStmt=153558576, column=3
      value=15
      Fetching (SQLFetch), hStmt=153558576
      Get string data (SQLGetData), hStmt=153558576, column=1, maxLen=129
      DATETIME
      Get integer data (SQLGetData), hStmt=153558576, column=2
      value=11
      Get integer data (SQLGetData), hStmt=153558576, column=3
      value=19
      Fetching (SQLFetch), hStmt=153558576
      Get string data (SQLGetData), hStmt=153558576, column=1, maxLen=129
      VARCHAR
      Get integer data (SQLGetData), hStmt=153558576, column=2
      value=12
      Get integer data (SQLGetData), hStmt=153558576, column=3
      value=255
      Fetching (SQLFetch), hStmt=153558576
      End of result set (SQL_NO_DATA)
      Free statement (SQLFreeStmt), hStmt=153558576, fOption=1
      Get connection info (SQLGetInfo), hDbc=153555536, fInfoType=44
       int value=19
      Get connection info (SQLGetInfo), hDbc=153555536, fInfoType=168
       int value=1
      Get connection info (SQLGetInfo), hDbc=153555536, fInfoType=151
       int value=127
      Get connection info (SQLGetInfo), hDbc=153555536, fInfoType=121
       int value=0
      Get connection info (SQLGetInfo), hDbc=153555536, fInfoType=120
       int value=0
      Get connection info (SQLGetInfo), hDbc=153555536, fInfoType=153
       int value=2
      getConnection returning driver[className=sun.jdbc.odbc.JdbcOdbcDriver,sun.jdbc.o
      dbc.JdbcOdbcDriver@50169]
      ================================================================================
      und it works...
      (Review ID: 100404)
      ======================================================================

            jellissunw Jon Ellis (Inactive)
            kryansunw Kevin Ryan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: