List of usage examples for java.sql Clob toString
public String toString()
From source file:org.openanzo.jdbc.container.sql.TransactionSQL.java
/** * Runs the udpateChangeset prepared statement. * <code>//from w w w . j av a 2s. c o m * UPDATE {0} SET ADDGRAPH=?,REMOVEGRAPH=? ,METAADDGRAPH=?,METAREMOVEGRAPH=? WHERE ID=? * </code> * *@param stmtProvider * factory and cache of PreparedStatments *@param connection * connection to underlying database * *@param addGraph template parameter *@param removeGraph template parameter *@param addMetaGraph template parameter *@param removeMetaGraph template parameter *@param id template parameter * *@param transactionTableName template parameter *@return int *@throws org.openanzo.jdbc.utils.RdbException */ public static int udpateChangeset(final org.openanzo.jdbc.utils.PreparedStatementProvider stmtProvider, final java.sql.Connection connection, java.sql.Clob addGraph, java.sql.Clob removeGraph, java.sql.Clob addMetaGraph, java.sql.Clob removeMetaGraph, long id, String transactionTableName) throws org.openanzo.jdbc.utils.RdbException { java.sql.PreparedStatement ps = null; //long startTimer=System.currentTimeMillis(); try { ps = stmtProvider.getPreparedSQLStatement(udpateChangeset, new String[] { transactionTableName }, connection); int argc = 1; if (addGraph == null) { ps.setNull(argc++, java.sql.Types.CLOB); } else { ps.setClob(argc++, addGraph); } if (removeGraph == null) { ps.setNull(argc++, java.sql.Types.CLOB); } else { ps.setClob(argc++, removeGraph); } if (addMetaGraph == null) { ps.setNull(argc++, java.sql.Types.CLOB); } else { ps.setClob(argc++, addMetaGraph); } if (removeMetaGraph == null) { ps.setNull(argc++, java.sql.Types.CLOB); } else { ps.setClob(argc++, removeMetaGraph); } ps.setLong(argc++, id); int counter = 0; try { counter = ps.executeUpdate(); } catch (java.sql.SQLException sqle) { if (sqle.getErrorCode() == 1205) { int retries = 0; while (retries < 5) { try { Thread.sleep(5000); } catch (InterruptedException ie) { throw sqle; } try { counter = ps.executeUpdate(); break; } catch (java.sql.SQLException sqleInner) { if (sqleInner.getErrorCode() == 1205) { retries++; } else { throw sqleInner; } } } if (retries >= 5) { throw sqle; } } else { throw sqle; } } return counter; } catch (java.sql.SQLException e) { throw new org.openanzo.jdbc.utils.RdbException( org.openanzo.exceptions.ExceptionConstants.RDB.FAILED_EXECUTING_SQL, e, "udpateChangeset", stmtProvider.getSqlString(udpateChangeset), "" + "addGraph=" + ((addGraph != null) ? addGraph.toString() : "null") + "," + "removeGraph=" + ((removeGraph != null) ? removeGraph.toString() : "null") + "," + "addMetaGraph=" + ((addMetaGraph != null) ? addMetaGraph.toString() : "null") + "," + "removeMetaGraph=" + ((removeMetaGraph != null) ? removeMetaGraph.toString() : "null") + "," + "id=" + (id), "" + "transactionTableName=" + ((transactionTableName != null) ? transactionTableName.toString() : "null")); } finally { if (ps != null) { try { ps.close(); } catch (java.sql.SQLException sqle) { if (log.isDebugEnabled()) log.debug(org.openanzo.exceptions.LogUtils.RDB_MARKER, "Error closing prepared statement", sqle); } } //long endtimer=(System.currentTimeMillis()-startTimer); //if(endtimer>CUTOFF)System.out.println("[udpateChangeset]"+endtimer); } }
From source file:org.openanzo.jdbc.container.sql.TransactionSQL.java
/** * Runs the insertChangeset prepared statement. * <code>//from ww w . j a v a2 s. com * INSERT INTO {0} (commandId, addGraph,removeGraph,metaddgraph,metaremovegraph,namedGraphUri) VALUES (?, ?, ?, ?,?,?) * </code> * *@param stmtProvider * factory and cache of PreparedStatments *@param connection * connection to underlying database * *@param commandId template parameter *@param addGraph template parameter *@param removeGraph template parameter *@param addMetaGraph template parameter *@param removeMetaGraph template parameter *@param uri template parameter * *@param transactionTableName template parameter *@return int *@throws org.openanzo.jdbc.utils.RdbException */ public static int insertChangeset(final org.openanzo.jdbc.utils.PreparedStatementProvider stmtProvider, final java.sql.Connection connection, long commandId, java.sql.Clob addGraph, java.sql.Clob removeGraph, java.sql.Clob addMetaGraph, java.sql.Clob removeMetaGraph, String uri, String transactionTableName) throws org.openanzo.jdbc.utils.RdbException { java.sql.PreparedStatement ps = null; //long startTimer=System.currentTimeMillis(); try { ps = stmtProvider.getPreparedSQLStatement(insertChangeset, new String[] { transactionTableName }, connection); int argc = 1; ps.setLong(argc++, commandId); if (addGraph == null) { ps.setNull(argc++, java.sql.Types.CLOB); } else { ps.setClob(argc++, addGraph); } if (removeGraph == null) { ps.setNull(argc++, java.sql.Types.CLOB); } else { ps.setClob(argc++, removeGraph); } if (addMetaGraph == null) { ps.setNull(argc++, java.sql.Types.CLOB); } else { ps.setClob(argc++, addMetaGraph); } if (removeMetaGraph == null) { ps.setNull(argc++, java.sql.Types.CLOB); } else { ps.setClob(argc++, removeMetaGraph); } if (uri == null) { ps.setNull(argc++, java.sql.Types.VARCHAR); } else { ps.setString(argc++, uri); } int counter = 0; try { counter = ps.executeUpdate(); } catch (java.sql.SQLException sqle) { if (sqle.getErrorCode() == 1205) { int retries = 0; while (retries < 5) { try { Thread.sleep(5000); } catch (InterruptedException ie) { throw sqle; } try { counter = ps.executeUpdate(); break; } catch (java.sql.SQLException sqleInner) { if (sqleInner.getErrorCode() == 1205) { retries++; } else { throw sqleInner; } } } if (retries >= 5) { throw sqle; } } else { throw sqle; } } return counter; } catch (java.sql.SQLException e) { throw new org.openanzo.jdbc.utils.RdbException( org.openanzo.exceptions.ExceptionConstants.RDB.FAILED_EXECUTING_SQL, e, "insertChangeset", stmtProvider.getSqlString(insertChangeset), "" + "commandId=" + (commandId) + "," + "addGraph=" + ((addGraph != null) ? addGraph.toString() : "null") + "," + "removeGraph=" + ((removeGraph != null) ? removeGraph.toString() : "null") + "," + "addMetaGraph=" + ((addMetaGraph != null) ? addMetaGraph.toString() : "null") + "," + "removeMetaGraph=" + ((removeMetaGraph != null) ? removeMetaGraph.toString() : "null") + "," + "uri=" + ((uri != null) ? uri.toString() : "null"), "" + "transactionTableName=" + ((transactionTableName != null) ? transactionTableName.toString() : "null")); } finally { if (ps != null) { try { ps.close(); } catch (java.sql.SQLException sqle) { if (log.isDebugEnabled()) log.debug(org.openanzo.exceptions.LogUtils.RDB_MARKER, "Error closing prepared statement", sqle); } } //long endtimer=(System.currentTimeMillis()-startTimer); //if(endtimer>CUTOFF)System.out.println("[insertChangeset]"+endtimer); } }
From source file:org.openanzo.jdbc.container.sql.TransactionSQL.java
/** * Runs the updateCommand prepared statement. * <code>// ww w. j a va2 s. c om * UPDATE {0} set transactionId=?,commandType=?,context=?,preReq=? where id=? * </code> * *@param stmtProvider * factory and cache of PreparedStatments *@param connection * connection to underlying database * *@param transactionId template parameter *@param commandType template parameter *@param context template parameter *@param preReq template parameter *@param id template parameter * *@param transactionTableName template parameter *@return int *@throws org.openanzo.jdbc.utils.RdbException */ public static int updateCommand(final org.openanzo.jdbc.utils.PreparedStatementProvider stmtProvider, final java.sql.Connection connection, long transactionId, String commandType, java.sql.Clob context, java.sql.Clob preReq, long id, String transactionTableName) throws org.openanzo.jdbc.utils.RdbException { java.sql.PreparedStatement ps = null; //long startTimer=System.currentTimeMillis(); try { ps = stmtProvider.getPreparedSQLStatement(updateCommand, new String[] { transactionTableName }, connection); int argc = 1; ps.setLong(argc++, transactionId); if (commandType == null) { ps.setNull(argc++, java.sql.Types.VARCHAR); } else { ps.setString(argc++, commandType); } if (context == null) { ps.setNull(argc++, java.sql.Types.CLOB); } else { ps.setClob(argc++, context); } if (preReq == null) { ps.setNull(argc++, java.sql.Types.CLOB); } else { ps.setClob(argc++, preReq); } ps.setLong(argc++, id); int counter = 0; try { counter = ps.executeUpdate(); } catch (java.sql.SQLException sqle) { if (sqle.getErrorCode() == 1205) { int retries = 0; while (retries < 5) { try { Thread.sleep(5000); } catch (InterruptedException ie) { throw sqle; } try { counter = ps.executeUpdate(); break; } catch (java.sql.SQLException sqleInner) { if (sqleInner.getErrorCode() == 1205) { retries++; } else { throw sqleInner; } } } if (retries >= 5) { throw sqle; } } else { throw sqle; } } return counter; } catch (java.sql.SQLException e) { throw new org.openanzo.jdbc.utils.RdbException( org.openanzo.exceptions.ExceptionConstants.RDB.FAILED_EXECUTING_SQL, e, "updateCommand", stmtProvider.getSqlString(updateCommand), "" + "transactionId=" + (transactionId) + "," + "commandType=" + ((commandType != null) ? commandType.toString() : "null") + "," + "context=" + ((context != null) ? context.toString() : "null") + "," + "preReq=" + ((preReq != null) ? preReq.toString() : "null") + "," + "id=" + (id), "" + "transactionTableName=" + ((transactionTableName != null) ? transactionTableName.toString() : "null")); } finally { if (ps != null) { try { ps.close(); } catch (java.sql.SQLException sqle) { if (log.isDebugEnabled()) log.debug(org.openanzo.exceptions.LogUtils.RDB_MARKER, "Error closing prepared statement", sqle); } } //long endtimer=(System.currentTimeMillis()-startTimer); //if(endtimer>CUTOFF)System.out.println("[updateCommand]"+endtimer); } }
From source file:org.openanzo.jdbc.container.sql.TransactionSQL.java
/** * Runs the insertCommand prepared statement. * <code>/*w w w . jav a 2 s . co m*/ * INSERT INTO {0} (transactionId, commandType,context,prereq) VALUES (?, ?, ?, ?) * </code> * *@param stmtProvider * factory and cache of PreparedStatments *@param connection * connection to underlying database * *@param transactionId template parameter *@param commandType template parameter *@param context template parameter *@param preReq template parameter * *@param transactionTableName template parameter *@return int *@throws org.openanzo.jdbc.utils.RdbException */ public static int insertCommand(final org.openanzo.jdbc.utils.PreparedStatementProvider stmtProvider, final java.sql.Connection connection, long transactionId, String commandType, java.sql.Clob context, java.sql.Clob preReq, String transactionTableName) throws org.openanzo.jdbc.utils.RdbException { java.sql.PreparedStatement ps = null; //long startTimer=System.currentTimeMillis(); try { ps = stmtProvider.getPreparedSQLStatement(insertCommand, new String[] { transactionTableName }, connection); int argc = 1; ps.setLong(argc++, transactionId); if (commandType == null) { ps.setNull(argc++, java.sql.Types.VARCHAR); } else { ps.setString(argc++, commandType); } if (context == null) { ps.setNull(argc++, java.sql.Types.CLOB); } else { ps.setClob(argc++, context); } if (preReq == null) { ps.setNull(argc++, java.sql.Types.CLOB); } else { ps.setClob(argc++, preReq); } int counter = 0; try { counter = ps.executeUpdate(); } catch (java.sql.SQLException sqle) { if (sqle.getErrorCode() == 1205) { int retries = 0; while (retries < 5) { try { Thread.sleep(5000); } catch (InterruptedException ie) { throw sqle; } try { counter = ps.executeUpdate(); break; } catch (java.sql.SQLException sqleInner) { if (sqleInner.getErrorCode() == 1205) { retries++; } else { throw sqleInner; } } } if (retries >= 5) { throw sqle; } } else { throw sqle; } } return counter; } catch (java.sql.SQLException e) { throw new org.openanzo.jdbc.utils.RdbException( org.openanzo.exceptions.ExceptionConstants.RDB.FAILED_EXECUTING_SQL, e, "insertCommand", stmtProvider.getSqlString(insertCommand), "" + "transactionId=" + (transactionId) + "," + "commandType=" + ((commandType != null) ? commandType.toString() : "null") + "," + "context=" + ((context != null) ? context.toString() : "null") + "," + "preReq=" + ((preReq != null) ? preReq.toString() : "null"), "" + "transactionTableName=" + ((transactionTableName != null) ? transactionTableName.toString() : "null")); } finally { if (ps != null) { try { ps.close(); } catch (java.sql.SQLException sqle) { if (log.isDebugEnabled()) log.debug(org.openanzo.exceptions.LogUtils.RDB_MARKER, "Error closing prepared statement", sqle); } } //long endtimer=(System.currentTimeMillis()-startTimer); //if(endtimer>CUTOFF)System.out.println("[insertCommand]"+endtimer); } }