/** * Learn relevant information about this connection source. * */ public void discoverConnectionProperties() { Connection connection = null; try { connection = getConnection(); if (connection == null) { addWarn("Could not get a connection"); return; } DatabaseMetaData meta = connection.getMetaData(); DBUtil util = new DBUtil(); util.setContext(getContext()); supportsGetGeneratedKeys = util.supportsGetGeneratedKeys(meta); supportsBatchUpdates = util.supportsBatchUpdates(meta); dialectCode = DBUtil.discoverSQLDialect(meta); addInfo("Driver name="+meta.getDriverName()); addInfo("Driver version="+meta.getDriverVersion()); addInfo("supportsGetGeneratedKeys="+supportsGetGeneratedKeys); } catch (SQLException se) { addWarn("Could not discover the dialect to use.", se); } finally { DBHelper.closeConnection(connection); } }
/** * This method handles cases where the * {@link DatabaseMetaData#supportsGetGeneratedKeys} method is missing in the * JDBC driver implementation. */ public boolean supportsGetGeneratedKeys(DatabaseMetaData meta) { try { // // invoking JDBC 1.4 method by reflection // return ((Boolean) DatabaseMetaData.class.getMethod( "supportsGetGeneratedKeys", (Class[]) null).invoke(meta, (Object[]) null)).booleanValue(); } catch (Throwable e) { addInfo("Could not call supportsGetGeneratedKeys method. This may be recoverable"); return false; } }
@Override public void start() { if (connectionSource == null) { throw new IllegalStateException( "DBAppender cannot function without a connection source"); } sqlDialect = DBUtil .getDialectFromCode(connectionSource.getSQLDialectCode()); if (getGeneratedKeysMethod() != null) { cnxSupportsGetGeneratedKeys = connectionSource.supportsGetGeneratedKeys(); } else { cnxSupportsGetGeneratedKeys = false; } cnxSupportsBatchUpdates = connectionSource.supportsBatchUpdates(); if (!cnxSupportsGetGeneratedKeys && (sqlDialect == null)) { throw new IllegalStateException( "DBAppender cannot function if the JDBC driver does not support getGeneratedKeys method *and* without a specific SQL dialect"); } // all nice and dandy on the eastern front super.start(); }
DBUtil dbutilObject= new DBUtil (); //YOUR CONNECTION VARIABLE Connection con1 = dbutilObject.getDBConnection();
/** * Learn relevant information about this connection source. * */ public void discoverConnnectionProperties() { try { Connection connection = getConnection(); if (connection == null) { addWarn("Could not get a connection"); return; } DatabaseMetaData meta = connection.getMetaData(); DBUtil util = new DBUtil(); util.setContext(getContext()); supportsGetGeneratedKeys = util.supportsGetGeneratedKeys(meta); supportsBatchUpdates = util.supportsBatchUpdates(meta); dialectCode = DBUtil.discoverSQLDialect(meta); System.out.println("Driver name="+meta.getDriverName()); System.out.println("Driver version="+meta.getDriverVersion()); System.out.println("supportsGetGeneratedKeys="+supportsGetGeneratedKeys); } catch (SQLException se) { addWarn("Could not discover the dialect to use.", se); } }
/** * This method handles cases where the * {@link DatabaseMetaData#supportsBatchUpdates} method is missing in the JDBC * driver implementation. */ public boolean supportsBatchUpdates(DatabaseMetaData meta) { try { return meta.supportsBatchUpdates(); } catch (Throwable e) { addInfo("Missing DatabaseMetaData.supportsBatchUpdates method."); return false; } } }
@Override public void start() { if (connectionSource == null) { throw new IllegalStateException( "DBAppender cannot function without a connection source"); } sqlDialect = DBUtil .getDialectFromCode(connectionSource.getSQLDialectCode()); if (getGeneratedKeysMethod() != null) { cnxSupportsGetGeneratedKeys = connectionSource.supportsGetGeneratedKeys(); } else { cnxSupportsGetGeneratedKeys = false; } cnxSupportsBatchUpdates = connectionSource.supportsBatchUpdates(); if (!cnxSupportsGetGeneratedKeys && (sqlDialect == null)) { throw new IllegalStateException( "DBAppender cannot function if the JDBC driver does not support getGeneratedKeys method *and* without a specific SQL dialect"); } // all nice and dandy on the eastern front super.start(); }
/** * Learn relevant information about this connection source. * */ public void discoverConnectionProperties() { try { Connection connection = getConnection(); if (connection == null) { addWarn("Could not get a connection"); return; } DatabaseMetaData meta = connection.getMetaData(); DBUtil util = new DBUtil(); util.setContext(getContext()); supportsGetGeneratedKeys = util.supportsGetGeneratedKeys(meta); supportsBatchUpdates = util.supportsBatchUpdates(meta); dialectCode = DBUtil.discoverSQLDialect(meta); addInfo("Driver name="+meta.getDriverName()); addInfo("Driver version="+meta.getDriverVersion()); addInfo("supportsGetGeneratedKeys="+supportsGetGeneratedKeys); } catch (SQLException se) { addWarn("Could not discover the dialect to use.", se); } }
/** * This method handles cases where the * {@link DatabaseMetaData#supportsGetGeneratedKeys} method is missing in the * JDBC driver implementation. */ public boolean supportsGetGeneratedKeys(DatabaseMetaData meta) { try { // // invoking JDBC 1.4 method by reflection // return ((Boolean) DatabaseMetaData.class.getMethod("supportsGetGeneratedKeys", (Class[]) null).invoke(meta, (Object[]) null)).booleanValue(); } catch (Throwable e) { addInfo("Could not call supportsGetGeneratedKeys method. This may be recoverable"); return false; } }
@Override public void start() { if (connectionSource == null) { throw new IllegalStateException("DBAppender cannot function without a connection source"); } sqlDialect = DBUtil.getDialectFromCode(connectionSource.getSQLDialectCode()); if (getGeneratedKeysMethod() != null) { cnxSupportsGetGeneratedKeys = connectionSource.supportsGetGeneratedKeys(); } else { cnxSupportsGetGeneratedKeys = false; } cnxSupportsBatchUpdates = connectionSource.supportsBatchUpdates(); if (!cnxSupportsGetGeneratedKeys && (sqlDialect == null)) { throw new IllegalStateException( "DBAppender cannot function if the JDBC driver does not support getGeneratedKeys method *and* without a specific SQL dialect"); } // all nice and dandy on the eastern front super.start(); }
/** * Learn relevant information about this connection source. * */ public void discoverConnectionProperties() { try { Connection connection = getConnection(); if (connection == null) { addWarn("Could not get a connection"); return; } DatabaseMetaData meta = connection.getMetaData(); DBUtil util = new DBUtil(); util.setContext(getContext()); supportsGetGeneratedKeys = util.supportsGetGeneratedKeys(meta); supportsBatchUpdates = util.supportsBatchUpdates(meta); dialectCode = DBUtil.discoverSQLDialect(meta); addInfo("Driver name="+meta.getDriverName()); addInfo("Driver version="+meta.getDriverVersion()); addInfo("supportsGetGeneratedKeys="+supportsGetGeneratedKeys); } catch (SQLException se) { addWarn("Could not discover the dialect to use.", se); } }
/** * This method handles cases where the * {@link DatabaseMetaData#supportsGetGeneratedKeys} method is missing in the * JDBC driver implementation. */ public boolean supportsGetGeneratedKeys(DatabaseMetaData meta) { try { // // invoking JDBC 1.4 method by reflection // return ((Boolean) DatabaseMetaData.class.getMethod("supportsGetGeneratedKeys", (Class[]) null).invoke(meta, (Object[]) null)).booleanValue(); } catch (Throwable e) { addInfo("Could not call supportsGetGeneratedKeys method. This may be recoverable"); return false; } }
@Override public void start() { if (connectionSource == null) { throw new IllegalStateException("DBAppender cannot function without a connection source"); } sqlDialect = DBUtil.getDialectFromCode(connectionSource.getSQLDialectCode()); if (getGeneratedKeysMethod() != null) { cnxSupportsGetGeneratedKeys = connectionSource.supportsGetGeneratedKeys(); } else { cnxSupportsGetGeneratedKeys = false; } cnxSupportsBatchUpdates = connectionSource.supportsBatchUpdates(); if (!cnxSupportsGetGeneratedKeys && (sqlDialect == null)) { throw new IllegalStateException( "DBAppender cannot function if the JDBC driver does not support getGeneratedKeys method *and* without a specific SQL dialect"); } // all nice and dandy on the eastern front super.start(); }
/** * Learn relevant information about this connection source. * */ public void discoverConnectionProperties() { Connection connection = null; try { connection = getConnection(); if (connection == null) { addWarn("Could not get a connection"); return; } DatabaseMetaData meta = connection.getMetaData(); DBUtil util = new DBUtil(); util.setContext(getContext()); supportsGetGeneratedKeys = util.supportsGetGeneratedKeys(meta); supportsBatchUpdates = util.supportsBatchUpdates(meta); dialectCode = DBUtil.discoverSQLDialect(meta); addInfo("Driver name=" + meta.getDriverName()); addInfo("Driver version=" + meta.getDriverVersion()); addInfo("supportsGetGeneratedKeys=" + supportsGetGeneratedKeys); } catch (SQLException se) { addWarn("Could not discover the dialect to use.", se); } finally { DBHelper.closeConnection(connection); } }
/** * This method handles cases where the * {@link DatabaseMetaData#supportsGetGeneratedKeys} method is missing in the * JDBC driver implementation. */ public boolean supportsGetGeneratedKeys(DatabaseMetaData meta) { try { // // invoking JDBC 1.4 method by reflection // return ((Boolean) DatabaseMetaData.class.getMethod("supportsGetGeneratedKeys", (Class[]) null).invoke(meta, (Object[]) null)).booleanValue(); } catch (Throwable e) { addInfo("Could not call supportsGetGeneratedKeys method. This may be recoverable"); return false; } }
@Override public void start() { if (connectionSource == null) { throw new IllegalStateException("DBAppender cannot function without a connection source"); } sqlDialect = DBUtil.getDialectFromCode(connectionSource.getSQLDialectCode()); if (getGeneratedKeysMethod() != null) { cnxSupportsGetGeneratedKeys = connectionSource.supportsGetGeneratedKeys(); } else { cnxSupportsGetGeneratedKeys = false; } cnxSupportsBatchUpdates = connectionSource.supportsBatchUpdates(); if (!cnxSupportsGetGeneratedKeys && (sqlDialect == null)) { throw new IllegalStateException( "DBAppender cannot function if the JDBC driver does not support getGeneratedKeys method *and* without a specific SQL dialect"); } // all nice and dandy on the eastern front super.start(); }
/** * Learn relevant information about this connection source. * */ public void discoverConnectionProperties() { Connection connection = null; try { connection = getConnection(); if (connection == null) { addWarn("Could not get a connection"); return; } DatabaseMetaData meta = connection.getMetaData(); DBUtil util = new DBUtil(); util.setContext(getContext()); supportsGetGeneratedKeys = util.supportsGetGeneratedKeys(meta); supportsBatchUpdates = util.supportsBatchUpdates(meta); dialectCode = DBUtil.discoverSQLDialect(meta); addInfo("Driver name="+meta.getDriverName()); addInfo("Driver version="+meta.getDriverVersion()); addInfo("supportsGetGeneratedKeys="+supportsGetGeneratedKeys); } catch (SQLException se) { addWarn("Could not discover the dialect to use.", se); } finally { DBHelper.closeConnection(connection); } }
/** * This method handles cases where the * {@link DatabaseMetaData#supportsGetGeneratedKeys} method is missing in the * JDBC driver implementation. */ public boolean supportsGetGeneratedKeys(DatabaseMetaData meta) { try { // // invoking JDBC 1.4 method by reflection // return ((Boolean) DatabaseMetaData.class.getMethod( "supportsGetGeneratedKeys", (Class[]) null).invoke(meta, (Object[]) null)).booleanValue(); } catch (Throwable e) { addInfo("Could not call supportsGetGeneratedKeys method. This may be recoverable"); return false; } }
@Override public void start() { if (connectionSource == null) { throw new IllegalStateException( "DBAppender cannot function without a connection source"); } sqlDialect = DBUtil .getDialectFromCode(connectionSource.getSQLDialectCode()); if (getGeneratedKeysMethod() != null) { cnxSupportsGetGeneratedKeys = connectionSource.supportsGetGeneratedKeys(); } else { cnxSupportsGetGeneratedKeys = false; } cnxSupportsBatchUpdates = connectionSource.supportsBatchUpdates(); if (!cnxSupportsGetGeneratedKeys && (sqlDialect == null)) { throw new IllegalStateException( "DBAppender cannot function if the JDBC driver does not support getGeneratedKeys method *and* without a specific SQL dialect"); } // all nice and dandy on the eastern front super.start(); }
/** * Learn relevant information about this connection source. * */ public void discoverConnectionProperties() { Connection connection = null; try { connection = getConnection(); if (connection == null) { addWarn("Could not get a connection"); return; } DatabaseMetaData meta = connection.getMetaData(); DBUtil util = new DBUtil(); util.setContext(getContext()); supportsGetGeneratedKeys = util.supportsGetGeneratedKeys(meta); supportsBatchUpdates = util.supportsBatchUpdates(meta); dialectCode = DBUtil.discoverSQLDialect(meta); addInfo("Driver name=" + meta.getDriverName()); addInfo("Driver version=" + meta.getDriverVersion()); addInfo("supportsGetGeneratedKeys=" + supportsGetGeneratedKeys); } catch (SQLException se) { addWarn("Could not discover the dialect to use.", se); } finally { DBHelper.closeConnection(connection); } }