Beim Aufbau einer JDBC-Thin Verbindung zur Datenbank werden in der Regel viele Spalten der v$session mir festen Defaults gesetzt – ganz im Gegensatz zu einer SQL*Net Verbindung.
Dies lässt sich allerdings durch ein paar Zeilen Code sehr leicht beheben:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | public Connection openDBCon(String userId , String passWord , String xmldb , Logging l , SQLExcep ex) { Connection con = null; String nameForConnect = userId; String basisUrl = "jdbc:oracle:thin:@"; String driverName = "oracle.jdbc.driver.OracleDriver"; String Url = basisUrl + driverName; String myName = "ProgName"; // Name des Programms String hostName = InetAddress.getLocalHost().getCanonicalHostName(); String processName = myName + "@" + hostName; if (nameForConnect.equalsIgnoreCase("SYS")) { nameForConnect = nameForConnect + " as sysdba"; } try { Properties pro = new java.util.Properties(); pro.setProperty("password", passWord); pro.setProperty("user", nameForConnect); try { pro.put("ApplicationName", NotNull( myName, "ApplicationName")); pro.put("ClientHostname", NotNull( hostName, "ClientHostname")); pro.put("ClientUser", NotNull( System.getProperty("user.name"), "ClientUser")); pro.put("v$session.osuser", NotNull( System.getProperty("user.name"), "osuser")); pro.put("v$session.machine", NotNull( hostName, "machine")); pro.put("v$session.program", NotNull( myName + ".jar", "program")); pro.put("v$session.process", NotNull( processName, "process")); pro.put("v$session.terminal", NotNull( Strip(hostName), "terminal")); } catch (Exception ignore) { } DriverManager.registerDriver(new oracle.jdbc.OracleDriver()); Class.forName(driverName).newInstance(); con = DriverManager.getConnection(Url, pro); setDbMetaData(con.getMetaData()); setClientPro(con.getClientInfo()); return con; } catch (ClassNotFoundException e) { // Could not find the database driver System.out.println(e); e.printStackTrace(); } catch (SQLException sqle) { ex.printSQLException(sqle, xmldb, l); } catch (Exception e) { System.out.println(e); e.printStackTrace(); } return con; } |