Hi Experts,
I need help in JDBC Oracle OS Authentication, I searched the web and found out that there are 2 ways you can do this:
1. Set the property name outside the java code:
String url = "jdbc:oracle:thin:@oracleserver.mydomain.com:5521:SID"
Driver driver = new oracle.jdbc.OracleDriver();
DriverManager.registerDriver(driver);
Properties props = new Properties();
Connection conn = DriverManager.getConnection(url, props);
// Note that this needs to be set in the jvm when running the code:
java -Duser.name="User" ConnectManager
2. Set the property inside the code:
String url = "jdbc:oracle:thin:@oracleserver.mydomain.com:5521:SID"
Driver driver = new oracle.jdbc.OracleDriver();
DriverManager.registerDriver(driver);
Properties props = new Properties();
props.setProperty(OracleConnection.CONNECTION_PROPERTY_THIN_VSESSION_OSUSER,"User")
Connection conn = DriverManager.getConnection(url, props);
All codes above are based on this link: [http://forum.springsource.org/showthread.php?t=69428|http://forum.springsource.org/showthread.php?t=69428]
// Note however that this needs oracle 11g driver.
The system I am working on is using JDK 1.4 and Oracle 8 hence I am not able to use the 2nd option since I am not allowed to change the JDK and Oracle as there are dependent C applications installed.
So I went for option 1, however I am getting an invalid argument exception. I am starting to wonder if this is because I also need the latest oracle driver or I need to update the JDK. Please help here is the exception:
java.sql.SQLException: invalid arguments in call
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:1160)
at oracle.jdbc.ttc7.TTC7Protocol.logon(TTC7Protocol.java:183)
at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:346)
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:468)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:314)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:140)