static String getProductName(PersistenceManager pm) { JDOConnection jdoConn = pm.getDataStoreConnection(); try { return ((Connection)jdoConn.getNativeConnection()).getMetaData().getDatabaseProductName(); } catch (Throwable t) { LOG.warn("Error retrieving product name", t); return null; } finally { jdoConn.close(); // We must release the connection before we call other pm methods. } }
private static String getProductName(PersistenceManager pm) { JDOConnection jdoConn = pm.getDataStoreConnection(); try { return ((Connection)jdoConn.getNativeConnection()).getMetaData().getDatabaseProductName(); } catch (Throwable t) { LOG.warn("Error retrieving product name", t); return null; } finally { jdoConn.close(); // We must release the connection before we call other pm methods. } }
private void executeNoResult(final String queryText) throws SQLException { JDOConnection jdoConn = pm.getDataStoreConnection(); Statement statement = null; boolean doTrace = LOG.isDebugEnabled(); try { long start = doTrace ? System.nanoTime() : 0; statement = ((Connection)jdoConn.getNativeConnection()).createStatement(); statement.execute(queryText); MetastoreDirectSqlUtils.timingTrace(doTrace, queryText, start, doTrace ? System.nanoTime() : 0); } finally { if(statement != null){ statement.close(); } jdoConn.close(); // We must release the connection before we call other pm methods. } }
private void prepareQuotes() throws SQLException { if (dbType == DatabaseProduct.MYSQL) { assert pm.currentTransaction().isActive(); JDOConnection jdoConn = pm.getDataStoreConnection(); Statement statement = null; try { statement = ((Connection)jdoConn.getNativeConnection()).createStatement(); statement.execute("SET @@session.sql_mode=ANSI_QUOTES"); } finally { if(statement != null){ statement.close(); } jdoConn.close(); } } }
@Override public Connection getConnection() { return (Connection) this.persistenceManager.getDataStoreConnection(); }
public Connection getConnection() { return (Connection) this.persistenceManager.getDataStoreConnection(); }
public JDOConnection getDataStoreConnection() { return getPM().getDataStoreConnection(); }
private static String getProductName(PersistenceManager pm) { JDOConnection jdoConn = pm.getDataStoreConnection(); try { return ((Connection)jdoConn.getNativeConnection()).getMetaData().getDatabaseProductName(); } catch (Throwable t) { LOG.warn("Error retrieving product name", t); return null; } finally { jdoConn.close(); // We must release the connection before we call other pm methods. } }
private String getProductName() { JDOConnection jdoConn = pm.getDataStoreConnection(); try { return ((Connection)jdoConn.getNativeConnection()).getMetaData().getDatabaseProductName(); } catch (Throwable t) { LOG.warn("Error retrieving product name", t); return null; } finally { jdoConn.close(); // We must release the connection before we call other pm methods. } }
private void executeNoResult(final String queryText) throws SQLException { JDOConnection jdoConn = pm.getDataStoreConnection(); boolean doTrace = LOG.isDebugEnabled(); try { long start = doTrace ? System.nanoTime() : 0; ((Connection)jdoConn.getNativeConnection()).createStatement().execute(queryText); timingTrace(doTrace, queryText, start, doTrace ? System.nanoTime() : 0); } finally { jdoConn.close(); // We must release the connection before we call other pm methods. } }
private String getProductName() { JDOConnection jdoConn = pm.getDataStoreConnection(); try { return ((Connection)jdoConn.getNativeConnection()).getMetaData().getDatabaseProductName(); } catch (Throwable t) { LOG.warn("Error retrieving product name", t); return null; } finally { jdoConn.close(); // We must release the connection before we call other pm methods. } }
private void executeNoResult(final String queryText) throws SQLException { JDOConnection jdoConn = pm.getDataStoreConnection(); boolean doTrace = LOG.isDebugEnabled(); try { long start = doTrace ? System.nanoTime() : 0; ((Connection)jdoConn.getNativeConnection()).createStatement().execute(queryText); timingTrace(doTrace, queryText, start, doTrace ? System.nanoTime() : 0); } finally { jdoConn.close(); // We must release the connection before we call other pm methods. } }
private void prepareQuotes() throws SQLException { if (dbType == DatabaseProduct.MYSQL) { assert pm.currentTransaction().isActive(); JDOConnection jdoConn = pm.getDataStoreConnection(); Statement statement = null; try { statement = ((Connection)jdoConn.getNativeConnection()).createStatement(); statement.execute("SET @@session.sql_mode=ANSI_QUOTES"); } finally { if(statement != null){ statement.close(); } jdoConn.close(); } } }
/** * Get access to the statistics API of ZooDB. * @param pm The PersistenceManager * @return the statistics manager */ public static DBStatistics getStatistics(PersistenceManager pm) { DBTracer.logCall(ZooJdoHelper.class, pm); Session s = (Session) pm.getDataStoreConnection().getNativeConnection(); return new DBStatistics(s); } }
public static void main(String[] args) { String dbName; if (args.length == 0) { dbName = DB_NAME; } else { dbName = args[0]; } if (!ZooHelper.getDataStoreManager().dbExists(dbName)) { err.println("ERROR Database not found: " + dbName); return; } out.println("Checking database: " + dbName); ZooJdoProperties props = new ZooJdoProperties(dbName); PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory(props); PersistenceManager pm = pmf.getPersistenceManager(); Session s = (Session) pm.getDataStoreConnection().getNativeConnection(); String report = s.getPrimaryNode().checkDb(); out.println(); out.println("Report"); out.println("======"); out.println(report); out.println("======"); pm.close(); pmf.close(); out.println("Checking database done."); }
@Programmatic @Override public List<Map<String, Object>> executeSql(final String sql) { final JDOConnection dataStoreConnection = getJdoPersistenceManager().getDataStoreConnection(); try { final Object connectionObj = dataStoreConnection.getNativeConnection(); if(!(connectionObj instanceof java.sql.Connection)) { return null; } final java.sql.Connection connection = (java.sql.Connection) connectionObj; return executeSql(connection, sql); } finally { dataStoreConnection.close(); } }
@Programmatic @Override public Integer executeUpdate(final String sql) { final JDOConnection dataStoreConnection = getJdoPersistenceManager().getDataStoreConnection(); try { final Object connectionObj = dataStoreConnection.getNativeConnection(); if(!(connectionObj instanceof java.sql.Connection)) { return null; } final java.sql.Connection connection = (java.sql.Connection) connectionObj; return executeUpdate(connection, sql); } finally { dataStoreConnection.close(); } }