private Connection getJdbcConnection ( ) throws JspCoreException , SQLException { Connection conn = null ; String url = getConnProperties ( ) . getUrl ( ) ; String user = getConnProperties ( ) . getLoginUser ( ) ; String passwd = getConnProperties ( ) . getLoginPasswd ( ) ; String jndiName = getConnProperties ( ) . getJndiName ( ) ; //System.out.println("***** Query.getJdbcConnection(): jndiname = " + jndiName); if ( jndiName == null ) { // use driver manager // load driver String dbDriver = ( getConnProperties ( ) ) . getDbDriver ( ) ; try { Class . forName ( dbDriver ) ; conn = DriverManager . getConnection ( url , user , passwd ) ; } // try load driver catch ( ClassNotFoundException e ) { //com.ibm.ws.ffdc.FFDCFilter.processException(e, "com.ibm.ws.webcontainer.jsp.tsx.db.Query.getJdbcConnection", "174", this); throw new JspCoreException ( JspConstants . InvalidDbDriver + dbDriver ) ; } // catch } // if jndiname == null else { // use datasource DataSource ds ; try { ds = getSingleton ( jndiName ) ; } catch ( Throwable th ) { //com.ibm.ws.ffdc.FFDCFilter.processException(th, "com.ibm.ws.webcontainer.jsp.tsx.db.Query.getJdbcConnection", "184", this); throw new JspCoreException ( JspConstants . DatasourceException + th . getMessage ( ) ) ; } conn = ds . getConnection ( user , passwd ) ; } return conn ; }
Return a valid jdbc connection . if jndiName is specified then assume that we need to use a datasource else use a drivermanager