List of usage examples for java.sql Types SMALLINT
int SMALLINT
To view the source code for java.sql Types SMALLINT.
Click Source Link
The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type SMALLINT
.
From source file:org.jumpmind.symmetric.service.impl.DataLoaderService.java
public void insertIncomingError(ISqlTransaction transaction, IncomingError incomingError) { if (StringUtils.isNotBlank(incomingError.getNodeId()) && incomingError.getBatchId() >= 0) { transaction.prepareAndExecute(getSql("insertIncomingErrorSql"), new Object[] { incomingError.getBatchId(), incomingError.getNodeId(), incomingError.getFailedRowNumber(), incomingError.getFailedLineNumber(), incomingError.getTargetCatalogName(), incomingError.getTargetSchemaName(), incomingError.getTargetTableName(), incomingError.getEventType().getCode(), incomingError.getBinaryEncoding().name(), incomingError.getColumnNames(), incomingError.getPrimaryKeyColumnNames(), incomingError.getRowData(), incomingError.getOldData(), incomingError.getCurData(), incomingError.getResolveData(), incomingError.isResolveIgnore() ? 1 : 0, incomingError.getConflictId(), incomingError.getCreateTime(), incomingError.getLastUpdateBy(), incomingError.getLastUpdateTime() }, new int[] { Types.BIGINT, Types.VARCHAR, Types.BIGINT, Types.BIGINT, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.CHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.SMALLINT, Types.VARCHAR, Types.TIMESTAMP, Types.VARCHAR, Types.TIMESTAMP }); }// w w w . ja va 2 s . com }
From source file:net.sourceforge.msscodefactory.cfcrm.v2_1.CFCrmDb2LUW.CFCrmDb2LUWContactURLTable.java
public void updateContactURL(CFCrmAuthorization Authorization, CFCrmContactURLBuff Buff) { final String S_ProcName = "updateContactURL"; if ("CURL".equals(Buff.getClassCode()) && (!schema.isTenantUser(Authorization, Buff.getRequiredTenantId(), "UpdateContactURL"))) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Permission denied -- User not part of TSecGroup UpdateContactURL"); }/*from ww w.j av a2s . c o m*/ ResultSet resultSet = null; try { long TenantId = Buff.getRequiredTenantId(); long ContactURLId = Buff.getRequiredContactURLId(); long ContactId = Buff.getRequiredContactId(); Short URLProtocolId = Buff.getOptionalURLProtocolId(); String Name = Buff.getRequiredName(); String URL = Buff.getRequiredURL(); int Revision = Buff.getRequiredRevision(); Connection cnx = schema.getCnx(); final String sql = "CALL sp_update_ctcurl( ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + " )"; if (stmtUpdateByPKey == null) { stmtUpdateByPKey = cnx.prepareStatement(sql); } int argIdx = 1; stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtUpdateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtUpdateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtUpdateByPKey.setString(argIdx++, "CURL"); stmtUpdateByPKey.setLong(argIdx++, TenantId); stmtUpdateByPKey.setLong(argIdx++, ContactURLId); stmtUpdateByPKey.setLong(argIdx++, ContactId); if (URLProtocolId != null) { stmtUpdateByPKey.setShort(argIdx++, URLProtocolId.shortValue()); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.SMALLINT); } stmtUpdateByPKey.setString(argIdx++, Name); stmtUpdateByPKey.setString(argIdx++, URL); stmtUpdateByPKey.setInt(argIdx++, Revision); resultSet = stmtUpdateByPKey.executeQuery(); if (resultSet.next()) { CFCrmContactURLBuff updatedBuff = unpackContactURLResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } Buff.setRequiredContactId(updatedBuff.getRequiredContactId()); Buff.setOptionalURLProtocolId(updatedBuff.getOptionalURLProtocolId()); Buff.setRequiredName(updatedBuff.getRequiredName()); Buff.setRequiredURL(updatedBuff.getRequiredURL()); Buff.setRequiredRevision(updatedBuff.getRequiredRevision()); } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected a single-record response, " + resultSet.getRow() + " rows selected"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccDb2LUW.CFAccDb2LUWAddressTable.java
public CFAccAddressBuff[] readBuffByCountryIdx(CFAccAuthorization Authorization, Short CountryId) { final String S_ProcName = "readBuffByCountryIdx"; ResultSet resultSet = null;//from ww w . ja v a 2s .com try { Connection cnx = schema.getCnx(); final String sql = "CALL sp_read_address_by_countryidx( ?, ?, ?, ?, ?" + ", " + "?" + " )"; if (stmtReadBuffByCountryIdx == null) { stmtReadBuffByCountryIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtReadBuffByCountryIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByCountryIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByCountryIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByCountryIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByCountryIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); if (CountryId != null) { stmtReadBuffByCountryIdx.setShort(argIdx++, CountryId.shortValue()); } else { stmtReadBuffByCountryIdx.setNull(argIdx++, java.sql.Types.SMALLINT); } resultSet = stmtReadBuffByCountryIdx.executeQuery(); List<CFAccAddressBuff> buffList = new LinkedList<CFAccAddressBuff>(); while (resultSet.next()) { CFAccAddressBuff buff = unpackAddressResultSetToBuff(resultSet); buffList.add(buff); } int idx = 0; CFAccAddressBuff[] retBuff = new CFAccAddressBuff[buffList.size()]; Iterator<CFAccAddressBuff> iter = buffList.iterator(); while (iter.hasNext()) { retBuff[idx++] = iter.next(); } return (retBuff); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccOracle.CFAccOracleContactURLTable.java
public CFAccContactURLBuff[] readBuffByProtocolIdx(CFAccAuthorization Authorization, Short URLProtocolId) { final String S_ProcName = "readBuffByProtocolIdx"; ResultSet resultSet = null;//from w ww.j ava2s . c o m Connection cnx = schema.getCnx(); CallableStatement stmtReadBuffByProtocolIdx = null; List<CFAccContactURLBuff> buffList = new LinkedList<CFAccContactURLBuff>(); try { stmtReadBuffByProtocolIdx = cnx.prepareCall("begin " + schema.getLowerSchemaDbName() + ".rd_ctcurlbyprotocolidx( ?, ?, ?, ?, ?, ?" + ", " + "?" + " ); end;"); int argIdx = 1; stmtReadBuffByProtocolIdx.registerOutParameter(argIdx++, OracleTypes.CURSOR); stmtReadBuffByProtocolIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByProtocolIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByProtocolIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByProtocolIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByProtocolIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); if (URLProtocolId != null) { stmtReadBuffByProtocolIdx.setShort(argIdx++, URLProtocolId.shortValue()); } else { stmtReadBuffByProtocolIdx.setNull(argIdx++, java.sql.Types.SMALLINT); } stmtReadBuffByProtocolIdx.execute(); resultSet = (ResultSet) stmtReadBuffByProtocolIdx.getObject(1); if (resultSet != null) { try { while (resultSet.next()) { CFAccContactURLBuff buff = unpackContactURLResultSetToBuff(resultSet); buffList.add(buff); } try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } catch (SQLException e) { } } int idx = 0; CFAccContactURLBuff[] retBuff = new CFAccContactURLBuff[buffList.size()]; Iterator<CFAccContactURLBuff> iter = buffList.iterator(); while (iter.hasNext()) { retBuff[idx++] = iter.next(); } return (retBuff); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } if (stmtReadBuffByProtocolIdx != null) { try { stmtReadBuffByProtocolIdx.close(); } catch (SQLException e) { } stmtReadBuffByProtocolIdx = null; } } }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccPgSql.CFAccPgSqlAddressTable.java
public CFAccAddressBuff[] readBuffByCountryIdx(CFAccAuthorization Authorization, Short CountryId) { final String S_ProcName = "readBuffByCountryIdx"; ResultSet resultSet = null;/* www . j a v a 2 s. c o m*/ try { Connection cnx = schema.getCnx(); String sql = "SELECT * FROM " + schema.getLowerSchemaDbName() + ".sp_read_address_by_countryidx( ?, ?, ?, ?, ?" + ", " + "?" + " )"; if (stmtReadBuffByCountryIdx == null) { stmtReadBuffByCountryIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtReadBuffByCountryIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByCountryIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByCountryIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByCountryIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByCountryIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); if (CountryId != null) { stmtReadBuffByCountryIdx.setShort(argIdx++, CountryId.shortValue()); } else { stmtReadBuffByCountryIdx.setNull(argIdx++, java.sql.Types.SMALLINT); } resultSet = stmtReadBuffByCountryIdx.executeQuery(); List<CFAccAddressBuff> buffList = new LinkedList<CFAccAddressBuff>(); while (resultSet.next()) { CFAccAddressBuff buff = unpackAddressResultSetToBuff(resultSet); buffList.add(buff); } int idx = 0; CFAccAddressBuff[] retBuff = new CFAccAddressBuff[buffList.size()]; Iterator<CFAccAddressBuff> iter = buffList.iterator(); while (iter.hasNext()) { retBuff[idx++] = iter.next(); } return (retBuff); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccDb2LUW.CFAccDb2LUWContactTable.java
public CFAccContactBuff[] readBuffByTimezoneIdx(CFAccAuthorization Authorization, Short ISOTimezoneId) { final String S_ProcName = "readBuffByTimezoneIdx"; ResultSet resultSet = null;/*from ww w .j a v a 2 s . co m*/ try { Connection cnx = schema.getCnx(); final String sql = "CALL sp_read_contact_by_timezoneidx( ?, ?, ?, ?, ?" + ", " + "?" + " )"; if (stmtReadBuffByTimezoneIdx == null) { stmtReadBuffByTimezoneIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtReadBuffByTimezoneIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByTimezoneIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByTimezoneIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByTimezoneIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByTimezoneIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); if (ISOTimezoneId != null) { stmtReadBuffByTimezoneIdx.setShort(argIdx++, ISOTimezoneId.shortValue()); } else { stmtReadBuffByTimezoneIdx.setNull(argIdx++, java.sql.Types.SMALLINT); } resultSet = stmtReadBuffByTimezoneIdx.executeQuery(); List<CFAccContactBuff> buffList = new LinkedList<CFAccContactBuff>(); while (resultSet.next()) { CFAccContactBuff buff = unpackContactResultSetToBuff(resultSet); buffList.add(buff); } int idx = 0; CFAccContactBuff[] retBuff = new CFAccContactBuff[buffList.size()]; Iterator<CFAccContactBuff> iter = buffList.iterator(); while (iter.hasNext()) { retBuff[idx++] = iter.next(); } return (retBuff); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } }
From source file:org.openmrs.module.sync.api.db.hibernate.HibernateSyncDAO.java
public void exportChildDB(String uuidForChild, OutputStream os) throws DAOException { PrintStream out = new PrintStream(os); Set<String> tablesToSkip = new HashSet<String>(); {/*from ww w.j a v a 2 s. c o m*/ tablesToSkip.add("hl7_in_archive"); tablesToSkip.add("hl7_in_queue"); tablesToSkip.add("hl7_in_error"); tablesToSkip.add("formentry_archive"); tablesToSkip.add("formentry_queue"); tablesToSkip.add("formentry_error"); tablesToSkip.add("sync_class"); tablesToSkip.add("sync_import"); tablesToSkip.add("sync_record"); tablesToSkip.add("sync_server"); tablesToSkip.add("sync_server_class"); tablesToSkip.add("sync_server_record"); // TODO: figure out which other tables to skip // tablesToSkip.add("obs"); // tablesToSkip.add("concept"); // tablesToSkip.add("patient"); } List<String> tablesToDump = new ArrayList<String>(); Session session = sessionFactory.getCurrentSession(); String schema = (String) session.createSQLQuery("SELECT schema()").uniqueResult(); log.warn("schema: " + schema); // Get all tables that we'll need to dump { Query query = session.createSQLQuery( "SELECT tabs.table_name FROM INFORMATION_SCHEMA.TABLES tabs WHERE tabs.table_schema = '" + schema + "'"); for (Object tn : query.list()) { String tableName = (String) tn; if (!tablesToSkip.contains(tableName.toLowerCase())) tablesToDump.add(tableName); } } log.warn("tables to dump: " + tablesToDump); String thisServerGuid = getGlobalProperty(SyncConstants.PROPERTY_SERVER_UUID); // Write the DDL Header as mysqldump does { out.println("-- ------------------------------------------------------"); out.println("-- Database dump to create an openmrs child server"); out.println("-- Schema: " + schema); out.println("-- Parent GUID: " + thisServerGuid); out.println("-- Parent version: " + OpenmrsConstants.OPENMRS_VERSION); out.println("-- ------------------------------------------------------"); out.println(""); out.println("/*!40101 SET CHARACTER_SET_CLIENT=utf8 */;"); out.println("/*!40101 SET NAMES utf8 */;"); out.println("/*!40103 SET TIME_ZONE='+00:00' */;"); out.println("/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;"); out.println("/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;"); out.println("/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;"); out.println("/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;"); out.println("/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;"); out.println("/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;"); out.println("/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;"); out.println("/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;"); out.println(""); } try { // JDBC way of doing this // Connection conn = // DriverManager.getConnection("jdbc:mysql://localhost/" + schema, // "test", "test"); Connection conn = sessionFactory.getCurrentSession().connection(); try { Statement st = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); // Get the create database statement ResultSet rs = st.executeQuery("SHOW CREATE DATABASE " + schema); for (String tableName : tablesToDump) { out.println(); out.println("--"); out.println("-- Table structure for table `" + tableName + "`"); out.println("--"); out.println("DROP TABLE IF EXISTS `" + tableName + "`;"); out.println("SET @saved_cs_client = @@character_set_client;"); out.println("SET character_set_client = utf8;"); rs = st.executeQuery("SHOW CREATE TABLE " + tableName); while (rs.next()) { out.println(rs.getString("Create Table") + ";"); } out.println("SET character_set_client = @saved_cs_client;"); out.println(); { out.println("-- Dumping data for table `" + tableName + "`"); out.println("LOCK TABLES `" + tableName + "` WRITE;"); out.println("/*!40000 ALTER TABLE `" + tableName + "` DISABLE KEYS */;"); boolean first = true; rs = st.executeQuery("select * from " + tableName); ResultSetMetaData md = rs.getMetaData(); int numColumns = md.getColumnCount(); int rowNum = 0; boolean insert = false; while (rs.next()) { if (rowNum == 0) { insert = true; out.print("INSERT INTO `" + tableName + "` VALUES "); } ++rowNum; if (first) { first = false; } else { out.print(", "); } if (rowNum % 20 == 0) { out.println(); } out.print("("); for (int i = 1; i <= numColumns; ++i) { if (i != 1) { out.print(","); } if (rs.getObject(i) == null) { out.print("NULL"); } else { switch (md.getColumnType(i)) { case Types.VARCHAR: case Types.CHAR: case Types.LONGVARCHAR: out.print("'"); out.print( rs.getString(i).replaceAll("\n", "\\\\n").replaceAll("'", "\\\\'")); out.print("'"); break; case Types.BIGINT: case Types.DECIMAL: case Types.NUMERIC: out.print(rs.getBigDecimal(i)); break; case Types.BIT: out.print(rs.getBoolean(i)); break; case Types.INTEGER: case Types.SMALLINT: case Types.TINYINT: out.print(rs.getInt(i)); break; case Types.REAL: case Types.FLOAT: case Types.DOUBLE: out.print(rs.getDouble(i)); break; case Types.BLOB: case Types.VARBINARY: case Types.LONGVARBINARY: Blob blob = rs.getBlob(i); out.print("'"); InputStream in = blob.getBinaryStream(); while (true) { int b = in.read(); if (b < 0) { break; } char c = (char) b; if (c == '\'') { out.print("\'"); } else { out.print(c); } } out.print("'"); break; case Types.CLOB: out.print("'"); out.print( rs.getString(i).replaceAll("\n", "\\\\n").replaceAll("'", "\\\\'")); out.print("'"); break; case Types.DATE: out.print("'" + rs.getDate(i) + "'"); break; case Types.TIMESTAMP: out.print("'" + rs.getTimestamp(i) + "'"); break; default: throw new RuntimeException("TODO: handle type code " + md.getColumnType(i) + " (name " + md.getColumnTypeName(i) + ")"); } } } out.print(")"); } if (insert) { out.println(";"); insert = false; } out.println("/*!40000 ALTER TABLE `" + tableName + "` ENABLE KEYS */;"); out.println("UNLOCK TABLES;"); out.println(); } } } finally { conn.close(); } // Now we mark this as a child out.println("-- Now mark this as a child database"); if (uuidForChild == null) uuidForChild = SyncUtil.generateUuid(); out.println("update global_property set property_value = '" + uuidForChild + "' where property = '" + SyncConstants.PROPERTY_SERVER_UUID + "';"); // Write the footer of the DDL script { out.println("/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;"); out.println("/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;"); out.println("/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;"); out.println("/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;"); out.println("/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;"); out.println("/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;"); out.println("/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;"); out.println("/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;"); } out.flush(); out.close(); } catch (IOException ex) { log.error("IOException", ex); } catch (SQLException ex) { log.error("SQLException", ex); } }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccPgSql.CFAccPgSqlContactTable.java
public CFAccContactBuff[] readBuffByTimezoneIdx(CFAccAuthorization Authorization, Short ISOTimezoneId) { final String S_ProcName = "readBuffByTimezoneIdx"; ResultSet resultSet = null;//from w ww. java 2 s. c o m try { Connection cnx = schema.getCnx(); String sql = "SELECT * FROM " + schema.getLowerSchemaDbName() + ".sp_read_contact_by_timezoneidx( ?, ?, ?, ?, ?" + ", " + "?" + " )"; if (stmtReadBuffByTimezoneIdx == null) { stmtReadBuffByTimezoneIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtReadBuffByTimezoneIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByTimezoneIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByTimezoneIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByTimezoneIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByTimezoneIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); if (ISOTimezoneId != null) { stmtReadBuffByTimezoneIdx.setShort(argIdx++, ISOTimezoneId.shortValue()); } else { stmtReadBuffByTimezoneIdx.setNull(argIdx++, java.sql.Types.SMALLINT); } resultSet = stmtReadBuffByTimezoneIdx.executeQuery(); List<CFAccContactBuff> buffList = new LinkedList<CFAccContactBuff>(); while (resultSet.next()) { CFAccContactBuff buff = unpackContactResultSetToBuff(resultSet); buffList.add(buff); } int idx = 0; CFAccContactBuff[] retBuff = new CFAccContactBuff[buffList.size()]; Iterator<CFAccContactBuff> iter = buffList.iterator(); while (iter.hasNext()) { retBuff[idx++] = iter.next(); } return (retBuff); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccPgSql.CFAccPgSqlContactURLTable.java
public void updateContactURL(CFAccAuthorization Authorization, CFAccContactURLBuff Buff) { final String S_ProcName = "updateContactURL"; ResultSet resultSet = null;/*from w ww .j av a2s . c o m*/ try { long TenantId = Buff.getRequiredTenantId(); long ContactURLId = Buff.getRequiredContactURLId(); long ContactId = Buff.getRequiredContactId(); Short URLProtocolId = Buff.getOptionalURLProtocolId(); String Name = Buff.getRequiredName(); String URL = Buff.getRequiredURL(); int Revision = Buff.getRequiredRevision(); Connection cnx = schema.getCnx(); String sql = "select * from " + schema.getLowerSchemaDbName() + ".sp_update_ctcurl( ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + " )"; if (stmtUpdateByPKey == null) { stmtUpdateByPKey = cnx.prepareStatement(sql); } int argIdx = 1; stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtUpdateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtUpdateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtUpdateByPKey.setString(argIdx++, "CURL"); stmtUpdateByPKey.setLong(argIdx++, TenantId); stmtUpdateByPKey.setLong(argIdx++, ContactURLId); stmtUpdateByPKey.setLong(argIdx++, ContactId); if (URLProtocolId != null) { stmtUpdateByPKey.setShort(argIdx++, URLProtocolId.shortValue()); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.SMALLINT); } stmtUpdateByPKey.setString(argIdx++, Name); stmtUpdateByPKey.setString(argIdx++, URL); stmtUpdateByPKey.setInt(argIdx++, Revision); resultSet = stmtUpdateByPKey.executeQuery(); if (resultSet.next()) { CFAccContactURLBuff updatedBuff = unpackContactURLResultSetToBuff(resultSet); if (resultSet.next()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response"); } Buff.setRequiredContactId(updatedBuff.getRequiredContactId()); Buff.setOptionalURLProtocolId(updatedBuff.getOptionalURLProtocolId()); Buff.setRequiredName(updatedBuff.getRequiredName()); Buff.setRequiredURL(updatedBuff.getRequiredURL()); Buff.setRequiredRevision(updatedBuff.getRequiredRevision()); } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected a single-record response, " + resultSet.getRow() + " rows selected"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccDb2LUW.CFAccDb2LUWContactURLTable.java
public void updateContactURL(CFAccAuthorization Authorization, CFAccContactURLBuff Buff) { final String S_ProcName = "updateContactURL"; if ("CURL".equals(Buff.getClassCode()) && (!schema.isTenantUser(Authorization, Buff.getRequiredTenantId(), "UpdateContactURL"))) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Permission denied -- User not part of TSecGroup UpdateContactURL"); }//from w ww. j av a 2s .c o m ResultSet resultSet = null; try { long TenantId = Buff.getRequiredTenantId(); long ContactURLId = Buff.getRequiredContactURLId(); long ContactId = Buff.getRequiredContactId(); Short URLProtocolId = Buff.getOptionalURLProtocolId(); String Name = Buff.getRequiredName(); String URL = Buff.getRequiredURL(); int Revision = Buff.getRequiredRevision(); Connection cnx = schema.getCnx(); final String sql = "CALL sp_update_ctcurl( ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + " )"; if (stmtUpdateByPKey == null) { stmtUpdateByPKey = cnx.prepareStatement(sql); } int argIdx = 1; stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtUpdateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtUpdateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtUpdateByPKey.setString(argIdx++, "CURL"); stmtUpdateByPKey.setLong(argIdx++, TenantId); stmtUpdateByPKey.setLong(argIdx++, ContactURLId); stmtUpdateByPKey.setLong(argIdx++, ContactId); if (URLProtocolId != null) { stmtUpdateByPKey.setShort(argIdx++, URLProtocolId.shortValue()); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.SMALLINT); } stmtUpdateByPKey.setString(argIdx++, Name); stmtUpdateByPKey.setString(argIdx++, URL); stmtUpdateByPKey.setInt(argIdx++, Revision); resultSet = stmtUpdateByPKey.executeQuery(); if (resultSet.next()) { CFAccContactURLBuff updatedBuff = unpackContactURLResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } Buff.setRequiredContactId(updatedBuff.getRequiredContactId()); Buff.setOptionalURLProtocolId(updatedBuff.getOptionalURLProtocolId()); Buff.setRequiredName(updatedBuff.getRequiredName()); Buff.setRequiredURL(updatedBuff.getRequiredURL()); Buff.setRequiredRevision(updatedBuff.getRequiredRevision()); } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected a single-record response, " + resultSet.getRow() + " rows selected"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } }