public Connection getConnection() throws SQLException { Connection conn = null; try { if (dataSource == null) { dataSource = lookupDataSource(); } if(getUser() != null) { addWarn("Ignoring property [user] with value ["+getUser()+"] for obtaining a connection from a DataSource."); } conn = dataSource.getConnection(); } catch (final NamingException ne) { addError("Error while getting data source", ne); throw new SQLException("NamingException while looking up DataSource: " + ne.getMessage()); } catch (final ClassCastException cce) { addError("ClassCastException while looking up DataSource.", cce); throw new SQLException("ClassCastException while looking up DataSource: " + cce.getMessage()); } return conn; }
private DataSource lookupDataSource() throws NamingException, SQLException { addInfo("Looking up ["+jndiLocation+"] in JNDI"); DataSource ds; Context initialContext = new InitialContext(); Object obj = initialContext.lookup(jndiLocation); // PortableRemoteObject was introduced in JDK 1.3. We won't use it. // ds = (DataSource)PortableRemoteObject.narrow(obj, DataSource.class); ds = (DataSource) obj; if (ds == null) { throw new SQLException("Failed to obtain data source from JNDI location " + jndiLocation); } else { return ds; } } }
public void start() { if (jndiLocation == null) { addError("No JNDI location specified for JNDIConnectionSource."); } discoverConnectionProperties(); }
/** * @see org.apache.log4j.db.ConnectionSource#getConnection() */ public Connection getConnection() throws SQLException { Connection conn = null; try { if (dataSource == null) { dataSource = lookupDataSource(); } if (getUser() == null) { conn = dataSource.getConnection(); } else { conn = dataSource.getConnection(getUser(), getPassword()); } } catch (final NamingException ne) { addError("Error while getting data source", ne); throw new SQLException("NamingException while looking up DataSource: " + ne.getMessage()); } catch (final ClassCastException cce) { addError("ClassCastException while looking up DataSource.", cce); throw new SQLException("ClassCastException while looking up DataSource: " + cce.getMessage()); } return conn; }
/** * @see org.apache.log4j.spi.OptionHandler#activateOptions() */ public void start() { if (jndiLocation == null) { addError("No JNDI location specified for JNDIConnectionSource."); } discoverConnnectionProperties(); }
public Connection getConnection() throws SQLException { Connection conn = null; try { if (dataSource == null) { dataSource = lookupDataSource(); } if (getUser() != null) { addWarn("Ignoring property [user] with value [" + getUser() + "] for obtaining a connection from a DataSource."); } conn = dataSource.getConnection(); } catch (final NamingException ne) { addError("Error while getting data source", ne); throw new SQLException("NamingException while looking up DataSource: " + ne.getMessage()); } catch (final ClassCastException cce) { addError("ClassCastException while looking up DataSource.", cce); throw new SQLException("ClassCastException while looking up DataSource: " + cce.getMessage()); } return conn; }
public void start() { if (jndiLocation == null) { addError("No JNDI location specified for JNDIConnectionSource."); } discoverConnectionProperties(); }
private DataSource lookupDataSource() throws NamingException, SQLException { addInfo("Looking up ["+jndiLocation+"] in JNDI"); DataSource ds; Context initialContext = new InitialContext(); Object obj = initialContext.lookup(jndiLocation); // PortableRemoteObject was introduced in JDK 1.3. We won't use it. // ds = (DataSource)PortableRemoteObject.narrow(obj, DataSource.class); ds = (DataSource) obj; if (ds == null) { throw new SQLException("Failed to obtain data source from JNDI location " + jndiLocation); } else { return ds; } } }
public Connection getConnection() throws SQLException { Connection conn = null; try { if (dataSource == null) { dataSource = lookupDataSource(); } if (getUser() != null) { addWarn("Ignoring property [user] with value [" + getUser() + "] for obtaining a connection from a DataSource."); } conn = dataSource.getConnection(); } catch (final NamingException ne) { addError("Error while getting data source", ne); throw new SQLException("NamingException while looking up DataSource: " + ne.getMessage()); } catch (final ClassCastException cce) { addError("ClassCastException while looking up DataSource.", cce); throw new SQLException("ClassCastException while looking up DataSource: " + cce.getMessage()); } return conn; }
public void start() { if (jndiLocation == null) { addError("No JNDI location specified for JNDIConnectionSource."); } discoverConnectionProperties(); }
private DataSource lookupDataSource() throws NamingException, SQLException { addInfo("Looking up [" + jndiLocation + "] in JNDI"); DataSource ds; Context initialContext = new InitialContext(); Object obj = initialContext.lookup(jndiLocation); // PortableRemoteObject was introduced in JDK 1.3. We won't use it. // ds = (DataSource)PortableRemoteObject.narrow(obj, DataSource.class); ds = (DataSource) obj; if (ds == null) { throw new SQLException("Failed to obtain data source from JNDI location " + jndiLocation); } else { return ds; } } }
public Connection getConnection() throws SQLException { Connection conn = null; try { if (dataSource == null) { dataSource = lookupDataSource(); } if (getUser() != null) { addWarn("Ignoring property [user] with value [" + getUser() + "] for obtaining a connection from a DataSource."); } conn = dataSource.getConnection(); } catch (final NamingException ne) { addError("Error while getting data source", ne); throw new SQLException("NamingException while looking up DataSource: " + ne.getMessage()); } catch (final ClassCastException cce) { addError("ClassCastException while looking up DataSource.", cce); throw new SQLException("ClassCastException while looking up DataSource: " + cce.getMessage()); } return conn; }
public void start() { if (jndiLocation == null) { addError("No JNDI location specified for JNDIConnectionSource."); } discoverConnectionProperties(); }
private DataSource lookupDataSource() throws NamingException, SQLException { addInfo("Looking up [" + jndiLocation + "] in JNDI"); DataSource ds; Context initialContext = new InitialContext(); Object obj = initialContext.lookup(jndiLocation); // PortableRemoteObject was introduced in JDK 1.3. We won't use it. // ds = (DataSource)PortableRemoteObject.narrow(obj, DataSource.class); ds = (DataSource) obj; if (ds == null) { throw new SQLException("Failed to obtain data source from JNDI location " + jndiLocation); } else { return ds; } } }
public Connection getConnection() throws SQLException { Connection conn = null; try { if (dataSource == null) { dataSource = lookupDataSource(); } if(getUser() != null) { addWarn("Ignoring property [user] with value ["+getUser()+"] for obtaining a connection from a DataSource."); } conn = dataSource.getConnection(); } catch (final NamingException ne) { addError("Error while getting data source", ne); throw new SQLException("NamingException while looking up DataSource: " + ne.getMessage()); } catch (final ClassCastException cce) { addError("ClassCastException while looking up DataSource.", cce); throw new SQLException("ClassCastException while looking up DataSource: " + cce.getMessage()); } return conn; }
public void start() { if (jndiLocation == null) { addError("No JNDI location specified for JNDIConnectionSource."); } discoverConnectionProperties(); }
private DataSource lookupDataSource() throws NamingException, SQLException { addInfo("Looking up [" + jndiLocation + "] in JNDI"); DataSource ds; Context initialContext = new InitialContext(); Object obj = initialContext.lookup(jndiLocation); // PortableRemoteObject was introduced in JDK 1.3. We won't use it. // ds = (DataSource)PortableRemoteObject.narrow(obj, DataSource.class); ds = (DataSource) obj; if (ds == null) { throw new SQLException("Failed to obtain data source from JNDI location " + jndiLocation); } else { return ds; } } }
public Connection getConnection() throws SQLException { Connection conn = null; try { if (dataSource == null) { dataSource = lookupDataSource(); } if(getUser() != null) { addWarn("Ignoring property [user] with value ["+getUser()+"] for obtaining a connection from a DataSource."); } conn = dataSource.getConnection(); } catch (final NamingException ne) { addError("Error while getting data source", ne); throw new SQLException("NamingException while looking up DataSource: " + ne.getMessage()); } catch (final ClassCastException cce) { addError("ClassCastException while looking up DataSource.", cce); throw new SQLException("ClassCastException while looking up DataSource: " + cce.getMessage()); } return conn; }
public void start() { if (jndiLocation == null) { addError("No JNDI location specified for JNDIConnectionSource."); } discoverConnectionProperties(); }
private DataSource lookupDataSource() throws NamingException, SQLException { addInfo("Looking up ["+jndiLocation+"] in JNDI"); DataSource ds; Context initialContext = new InitialContext(); Object obj = initialContext.lookup(jndiLocation); // PortableRemoteObject was introduced in JDK 1.3. We won't use it. // ds = (DataSource)PortableRemoteObject.narrow(obj, DataSource.class); ds = (DataSource) obj; if (ds == null) { throw new SQLException("Failed to obtain data source from JNDI location " + jndiLocation); } else { return ds; } } }