public Connection getConnection ( String curDriverIn , String curCharsetIn , String curTrustStoreIn ) throws ClassNotFoundException , MalformedURLException , SQLException { // Local vars to satisfy compiler warnings String curDriver = curDriverIn ; String curCharset = curCharsetIn ; String curTrustStore = curTrustStoreIn ; Properties sysProps = System . getProperties ( ) ; if ( curDriver == null ) { // If explicit driver not specified curDriver = ( ( driver == null ) ? DEFAULT_JDBC_DRIVER : driver ) ; } if ( curCharset == null && charset != null ) { curCharset = charset ; } if ( curTrustStore == null && truststore != null ) { curTrustStore = truststore ; } if ( curCharset == null ) { sysProps . remove ( "sqlfile.charset" ) ; } else { sysProps . put ( "sqlfile.charset" , curCharset ) ; } if ( curTrustStore == null ) { sysProps . remove ( "javax.net.ssl.trustStore" ) ; } else { sysProps . put ( "javax.net.ssl.trustStore" , curTrustStore ) ; } String urlString = null ; try { urlString = expandSysPropVars ( url ) ; } catch ( IllegalArgumentException iae ) { throw new MalformedURLException ( iae . getMessage ( ) + " for URL '" + url + "'" ) ; } String userString = null ; if ( username != null ) try { userString = expandSysPropVars ( username ) ; } catch ( IllegalArgumentException iae ) { throw new MalformedURLException ( iae . getMessage ( ) + " for user name '" + username + "'" ) ; } String passwordString = null ; if ( password != null ) try { passwordString = expandSysPropVars ( password ) ; } catch ( IllegalArgumentException iae ) { throw new MalformedURLException ( iae . getMessage ( ) + " for password" ) ; } Class . forName ( curDriver ) ; // This is not necessary for jdbc:odbc or if class loaded by a // service resource file. Consider checking for that. Connection c = ( userString == null ) ? DriverManager . getConnection ( urlString ) : DriverManager . getConnection ( urlString , userString , passwordString ) ; if ( ti != null ) RCData . setTI ( c , ti ) ; // Would like to verify the setting made by checking // c.getTransactionIsolation(). Unfortunately, the spec allows for // databases to substitute levels according to some rules, and it's // impossible to know what to expect since custom levels are permitted. // Debug: // System.err.println("TI set to " + ti + "\nPOST: " // + SqlTool.tiToString(c.getTransactionIsolation())); return c ; }
Gets a JDBC Connection using the data of this RCData object with specified override elements