List of usage examples for java.sql Types TIMESTAMP
int TIMESTAMP
To view the source code for java.sql Types TIMESTAMP.
Click Source Link
The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type TIMESTAMP
.
From source file:edu.ncsa.sstde.indexing.postgis.PostgisIndexer.java
private int[] getSQLTypes(Object[] varNames) { int[] result = new int[varNames.length]; Map<String, LiteralDef> map = this.getSettings().getIndexGraph().getLiteralDefMap(); for (int i = 0; i < varNames.length; i++) { LiteralDef literalDef = map.get(varNames[i]); if (literalDef == null) { result[i] = Types.VARCHAR; } else if (DataTypeURI.isGeometry(literalDef.getType())) { result[i] = Types.OTHER; } else if (DataTypeURI.DATETIME.equals(literalDef.getType())) { result[i] = Types.TIMESTAMP; }/*from www. j a va 2 s .c o m*/ } return result; }
From source file:edu.ncsa.sstde.indexing.postgis.PostgisIndexer.java
private Object getSQLValue(Value value, int type) { if (type == Types.OTHER) { return IndexedStatement.asGeometry((Literal) value, true); } else if (type == Types.TIMESTAMP) { try {// ww w. ja va2 s. c o m return new java.sql.Timestamp(DateFormatter.getInstance().parse(value.stringValue()).getTime()); } catch (java.text.ParseException e) { e.printStackTrace(); } } else { return value.stringValue(); } return null; }
From source file:nl.ordina.bag.etl.dao.AbstractBAGDAO.java
@Override public void insertOpenbareRuimten(final List<OpenbareRuimte> openbareRuimten) throws DAOException { try {/*from ww w .j a v a 2 s . c o m*/ jdbcTemplate.batchUpdate("insert into bag_openbare_ruimte (" + "bag_openbare_ruimte_id," + "aanduiding_record_inactief," + "aanduiding_record_correctie," + "openbare_ruimte_naam," + "officieel," + "begindatum_tijdvak_geldigheid," + "einddatum_tijdvak_geldigheid," + "in_onderzoek," + "openbare_ruimte_type," + "bron_documentdatum," + "bron_documentnummer," + "openbareruimte_status," + "bag_woonplaats_id," + "verkorte_openbare_ruimte_naam" + ") values (?,?,?,?,?,?,?,?,?,?,?,?,?,?)", new BatchPreparedStatementSetter() { @Override public void setValues(PreparedStatement ps, int i) throws SQLException { ps.setLong(1, openbareRuimten.get(i).getIdentificatie()); ps.setInt(2, openbareRuimten.get(i).getAanduidingRecordInactief().ordinal()); ps.setLong(3, openbareRuimten.get(i).getAanduidingRecordCorrectie()); ps.setString(4, openbareRuimten.get(i).getOpenbareRuimteNaam()); ps.setInt(5, openbareRuimten.get(i).getOfficieel().ordinal()); ps.setTimestamp(6, new Timestamp( openbareRuimten.get(i).getBegindatumTijdvakGeldigheid().getTime())); if (openbareRuimten.get(i).getEinddatumTijdvakGeldigheid() == null) ps.setNull(7, Types.TIMESTAMP); else ps.setTimestamp(7, new Timestamp( openbareRuimten.get(i).getEinddatumTijdvakGeldigheid().getTime())); ps.setInt(8, openbareRuimten.get(i).getInOnderzoek().ordinal()); ps.setInt(9, openbareRuimten.get(i).getOpenbareRuimteType().ordinal()); ps.setDate(10, new Date(openbareRuimten.get(i).getDocumentdatum().getTime())); ps.setString(11, openbareRuimten.get(i).getDocumentnummer()); ps.setInt(12, openbareRuimten.get(i).getOpenbareruimteStatus().ordinal()); ps.setLong(13, openbareRuimten.get(i).getGerelateerdeWoonplaats()); ps.setString(14, openbareRuimten.get(i).getVerkorteOpenbareRuimteNaam()); } @Override public int getBatchSize() { return openbareRuimten.size(); } }); } catch (DataAccessException e) { throw new DAOException("Error inserting openbare ruimten", e); } }
From source file:org.jumpmind.vaadin.ui.sqlexplorer.TabularResultLayout.java
private void setEditor(Grid.Column gridColumn, Column tableColumn, List<TextField> primaryKeyEditors) { TextField editor = new TextField(); int typeCode = tableColumn.getMappedTypeCode(); switch (typeCode) { case Types.DATE: editor.setConverter(new ObjectConverter(Date.class, typeCode)); break;/*from w w w. j av a2s . c o m*/ case Types.TIME: editor.setConverter(new ObjectConverter(Time.class, typeCode)); break; case Types.TIMESTAMP: editor.setConverter(new ObjectConverter(Timestamp.class, typeCode)); break; case Types.BIT: editor.setConverter(new StringToBooleanConverter()); break; case Types.TINYINT: case Types.SMALLINT: case Types.BIGINT: case Types.INTEGER: editor.setConverter(new StringToLongConverter() { private static final long serialVersionUID = 1L; public NumberFormat getFormat(Locale locale) { NumberFormat format = super.getFormat(locale); format.setGroupingUsed(false); return format; } }); break; case Types.FLOAT: case Types.DOUBLE: case Types.REAL: case Types.NUMERIC: case Types.DECIMAL: editor.setConverter(new StringToBigDecimalConverter() { private static final long serialVersionUID = 1L; public NumberFormat getFormat(Locale locale) { NumberFormat format = super.getFormat(locale); format.setGroupingUsed(false); return format; } }); break; default: break; } editor.addValidator(new TableChangeValidator(editor, tableColumn)); editor.setNullRepresentation(""); if (!tableColumn.isRequired()) { editor.setNullSettingAllowed(true); } if (tableColumn.isPrimaryKey()) { primaryKeyEditors.add(editor); } gridColumn.setEditorField(editor); }
From source file:com.manydesigns.portofino.persistence.hibernate.HibernateConfig.java
public boolean setHibernateType(@Nullable SimpleValue value, com.manydesigns.portofino.model.database.Column column, Class javaType, final int jdbcType) { String typeName;/* www . j a va2 s .c o m*/ Properties typeParams = null; if (javaType == null) { return false; } if (javaType == Long.class) { typeName = LongType.INSTANCE.getName(); } else if (javaType == Short.class) { typeName = ShortType.INSTANCE.getName(); } else if (javaType == Integer.class) { typeName = IntegerType.INSTANCE.getName(); } else if (javaType == Byte.class) { typeName = ByteType.INSTANCE.getName(); } else if (javaType == Float.class) { typeName = FloatType.INSTANCE.getName(); } else if (javaType == Double.class) { typeName = DoubleType.INSTANCE.getName(); } else if (javaType == Character.class) { typeName = CharacterType.INSTANCE.getName(); } else if (javaType == String.class) { typeName = StringType.INSTANCE.getName(); } else if (java.util.Date.class.isAssignableFrom(javaType)) { switch (jdbcType) { case Types.DATE: typeName = DateType.INSTANCE.getName(); break; case Types.TIME: typeName = TimeType.INSTANCE.getName(); break; case Types.TIMESTAMP: typeName = TimestampType.INSTANCE.getName(); break; default: typeName = null; } } else if (javaType == Boolean.class) { if (jdbcType == Types.BIT || jdbcType == Types.BOOLEAN) { typeName = BooleanType.INSTANCE.getName(); } else if (jdbcType == Types.NUMERIC || jdbcType == Types.DECIMAL || jdbcType == Types.INTEGER || jdbcType == Types.SMALLINT || jdbcType == Types.TINYINT || jdbcType == Types.BIGINT) { typeName = NumericBooleanType.INSTANCE.getName(); } else if (jdbcType == Types.CHAR || jdbcType == Types.VARCHAR) { typeName = StringBooleanType.class.getName(); typeParams = new Properties(); typeParams.setProperty("true", trueString != null ? trueString : StringBooleanType.NULL); typeParams.setProperty("false", falseString != null ? falseString : StringBooleanType.NULL); typeParams.setProperty("sqlType", String.valueOf(jdbcType)); } else { typeName = null; } } else if (javaType == BigDecimal.class) { typeName = BigDecimalType.INSTANCE.getName(); } else if (javaType == BigInteger.class) { typeName = BigIntegerType.INSTANCE.getName(); } else if (javaType == byte[].class) { typeName = BlobType.INSTANCE.getName(); } else { typeName = null; } if (typeName == null) { logger.error("Unsupported type (java type: {}, jdbc type: {}) " + "for column '{}'.", new Object[] { javaType, jdbcType, column.getColumnName() }); return false; } if (value != null) { value.setTypeName(typeName); if (typeParams != null) { value.setTypeParameters(typeParams); } } return true; }
From source file:org.dspace.storage.rdbms.DatabaseManager.java
/** * Convert the current row in a ResultSet into a TableRow object. * * @param results/* www . ja va 2 s . co m*/ * A ResultSet to process * @param table * The name of the table * @param pColumnNames * The name of the columns in this resultset * @return A TableRow object with the data from the ResultSet * @exception SQLException * If a database error occurs */ static TableRow process(ResultSet results, String table, List<String> pColumnNames) throws SQLException { ResultSetMetaData meta = results.getMetaData(); int columns = meta.getColumnCount() + 1; // If we haven't been passed the column names try to generate them from the metadata / table List<String> columnNames = pColumnNames != null ? pColumnNames : ((table == null) ? getColumnNames(meta) : getColumnNames(table)); TableRow row = new TableRow(canonicalize(table), columnNames); // Process the columns in order // (This ensures maximum backwards compatibility with // old JDBC drivers) for (int i = 1; i < columns; i++) { String name = meta.getColumnName(i); int jdbctype = meta.getColumnType(i); switch (jdbctype) { case Types.BIT: row.setColumn(name, results.getBoolean(i)); break; case Types.INTEGER: case Types.NUMERIC: if (isOracle) { long longValue = results.getLong(i); if (longValue <= (long) Integer.MAX_VALUE) { row.setColumn(name, (int) longValue); } else { row.setColumn(name, longValue); } } else { row.setColumn(name, results.getInt(i)); } break; case Types.DECIMAL: case Types.BIGINT: row.setColumn(name, results.getLong(i)); break; case Types.DOUBLE: row.setColumn(name, results.getDouble(i)); break; case Types.CLOB: if (isOracle) { row.setColumn(name, results.getString(i)); } else { throw new IllegalArgumentException("Unsupported JDBC type: " + jdbctype); } break; case Types.VARCHAR: try { byte[] bytes = results.getBytes(i); if (bytes != null) { String mystring = new String(results.getBytes(i), "UTF-8"); row.setColumn(name, mystring); } else { row.setColumn(name, results.getString(i)); } } catch (UnsupportedEncodingException e) { log.error("Unable to parse text from database", e); } break; case Types.DATE: row.setColumn(name, results.getDate(i)); break; case Types.TIME: row.setColumn(name, results.getTime(i)); break; case Types.TIMESTAMP: row.setColumn(name, results.getTimestamp(i)); break; default: throw new IllegalArgumentException("Unsupported JDBC type: " + jdbctype); } // Determines if the last column was null, and sets the tablerow accordingly if (results.wasNull()) { row.setColumnNull(name); } } // Now that we've prepped the TableRow, reset the flags so that we can detect which columns have changed row.resetChanged(); return row; }
From source file:com.flexive.core.storage.GenericDivisionImporter.java
/** * Import data from a zip archive to a database table * * @param stmt statement to use * @param zip zip archive containing the zip entry * @param ze zip entry within the archive * @param xpath xpath containing the entries to import * @param table name of the table * @param executeInsertPhase execute the insert phase? * @param executeUpdatePhase execute the update phase? * @param updateColumns columns that should be set to <code>null</code> in a first pass (insert) * and updated to the provided values in a second pass (update), * columns that should be used in the where clause have to be prefixed * with "KEY:", to assign a default value use the expression "columnname:default value", * if the default value is "@", it will be a negative counter starting at 0, decreasing. * If the default value starts with "%", it will be set to the column following the "%" * character in the first pass * @throws Exception on errors/*from ww w .ja va2 s . c om*/ */ protected void importTable(Statement stmt, final ZipFile zip, final ZipEntry ze, final String xpath, final String table, final boolean executeInsertPhase, final boolean executeUpdatePhase, final String... updateColumns) throws Exception { //analyze the table final ResultSet rs = stmt.executeQuery("SELECT * FROM " + table + " WHERE 1=2"); StringBuilder sbInsert = new StringBuilder(500); StringBuilder sbUpdate = updateColumns.length > 0 ? new StringBuilder(500) : null; if (rs == null) throw new IllegalArgumentException("Can not analyze table [" + table + "]!"); sbInsert.append("INSERT INTO ").append(table).append(" ("); final ResultSetMetaData md = rs.getMetaData(); final Map<String, ColumnInfo> updateClauseColumns = updateColumns.length > 0 ? new HashMap<String, ColumnInfo>(md.getColumnCount()) : null; final Map<String, ColumnInfo> updateSetColumns = updateColumns.length > 0 ? new LinkedHashMap<String, ColumnInfo>(md.getColumnCount()) : null; final Map<String, String> presetColumns = updateColumns.length > 0 ? new HashMap<String, String>(10) : null; //preset to a referenced column (%column syntax) final Map<String, String> presetRefColumns = updateColumns.length > 0 ? new HashMap<String, String>(10) : null; final Map<String, Integer> counters = updateColumns.length > 0 ? new HashMap<String, Integer>(10) : null; final Map<String, ColumnInfo> insertColumns = new HashMap<String, ColumnInfo>( md.getColumnCount() + (counters != null ? counters.size() : 0)); int insertIndex = 1; int updateSetIndex = 1; int updateClauseIndex = 1; boolean first = true; for (int i = 0; i < md.getColumnCount(); i++) { final String currCol = md.getColumnName(i + 1).toLowerCase(); if (updateColumns.length > 0) { boolean abort = false; for (String col : updateColumns) { if (col.indexOf(':') > 0 && !col.startsWith("KEY:")) { String value = col.substring(col.indexOf(':') + 1); col = col.substring(0, col.indexOf(':')); if ("@".equals(value)) { if (currCol.equalsIgnoreCase(col)) { counters.put(col, 0); insertColumns.put(col, new ColumnInfo(md.getColumnType(i + 1), insertIndex++)); sbInsert.append(',').append(currCol); } } else if (value.startsWith("%")) { if (currCol.equalsIgnoreCase(col)) { presetRefColumns.put(col, value.substring(1)); insertColumns.put(col, new ColumnInfo(md.getColumnType(i + 1), insertIndex++)); sbInsert.append(',').append(currCol); // System.out.println("==> adding presetRefColumn "+col+" with value of "+value.substring(1)); } } else if (!presetColumns.containsKey(col)) presetColumns.put(col, value); } if (currCol.equalsIgnoreCase(col)) { abort = true; updateSetColumns.put(currCol, new ColumnInfo(md.getColumnType(i + 1), updateSetIndex++)); break; } } if (abort) continue; } if (first) { first = false; } else sbInsert.append(','); sbInsert.append(currCol); insertColumns.put(currCol, new ColumnInfo(md.getColumnType(i + 1), insertIndex++)); } if (updateColumns.length > 0 && executeUpdatePhase) { sbUpdate.append("UPDATE ").append(table).append(" SET "); int counter = 0; for (String updateColumn : updateSetColumns.keySet()) { if (counter++ > 0) sbUpdate.append(','); sbUpdate.append(updateColumn).append("=?"); } sbUpdate.append(" WHERE "); boolean hasKeyColumn = false; for (String col : updateColumns) { if (!col.startsWith("KEY:")) continue; hasKeyColumn = true; String keyCol = col.substring(4); for (int i = 0; i < md.getColumnCount(); i++) { if (!md.getColumnName(i + 1).equalsIgnoreCase(keyCol)) continue; updateClauseColumns.put(keyCol, new ColumnInfo(md.getColumnType(i + 1), updateClauseIndex++)); sbUpdate.append(keyCol).append("=? AND "); break; } } if (!hasKeyColumn) throw new IllegalArgumentException("Update columns require a KEY!"); sbUpdate.delete(sbUpdate.length() - 5, sbUpdate.length()); //remove trailing " AND " //"shift" clause indices for (String col : updateClauseColumns.keySet()) { GenericDivisionImporter.ColumnInfo ci = updateClauseColumns.get(col); ci.index += (updateSetIndex - 1); } } if (presetColumns != null) { for (String key : presetColumns.keySet()) sbInsert.append(',').append(key); } sbInsert.append(")VALUES("); for (int i = 0; i < insertColumns.size(); i++) { if (i > 0) sbInsert.append(','); sbInsert.append('?'); } if (presetColumns != null) { for (String key : presetColumns.keySet()) sbInsert.append(',').append(presetColumns.get(key)); } sbInsert.append(')'); if (DBG) { LOG.info("Insert statement:\n" + sbInsert.toString()); if (updateColumns.length > 0) LOG.info("Update statement:\n" + sbUpdate.toString()); } //build a map containing all nodes that require attributes //this allows for matching simple xpath queries like "flatstorages/storage[@name='FX_FLAT_STORAGE']/data" final Map<String, List<String>> queryAttributes = new HashMap<String, List<String>>(5); for (String pElem : xpath.split("/")) { if (!(pElem.indexOf('@') > 0 && pElem.indexOf('[') > 0)) continue; List<String> att = new ArrayList<String>(5); for (String pAtt : pElem.split("@")) { if (!(pAtt.indexOf('=') > 0)) continue; att.add(pAtt.substring(0, pAtt.indexOf('='))); } queryAttributes.put(pElem.substring(0, pElem.indexOf('[')), att); } final PreparedStatement psInsert = stmt.getConnection().prepareStatement(sbInsert.toString()); final PreparedStatement psUpdate = updateColumns.length > 0 && executeUpdatePhase ? stmt.getConnection().prepareStatement(sbUpdate.toString()) : null; try { final SAXParser parser = SAXParserFactory.newInstance().newSAXParser(); final DefaultHandler handler = new DefaultHandler() { private String currentElement = null; private Map<String, String> data = new HashMap<String, String>(10); private StringBuilder sbData = new StringBuilder(10000); boolean inTag = false; boolean inElement = false; int counter; List<String> path = new ArrayList<String>(10); StringBuilder currPath = new StringBuilder(100); boolean insertMode = true; /** * {@inheritDoc} */ @Override public void startDocument() throws SAXException { counter = 0; inTag = false; inElement = false; path.clear(); currPath.setLength(0); sbData.setLength(0); data.clear(); currentElement = null; } /** * {@inheritDoc} */ @Override public void processingInstruction(String target, String data) throws SAXException { if (target != null && target.startsWith("fx_")) { if (target.equals("fx_mode")) insertMode = "insert".equals(data); } else super.processingInstruction(target, data); } /** * {@inheritDoc} */ @Override public void endDocument() throws SAXException { if (insertMode) LOG.info("Imported [" + counter + "] entries into [" + table + "] for xpath [" + xpath + "]"); else LOG.info("Updated [" + counter + "] entries in [" + table + "] for xpath [" + xpath + "]"); } /** * {@inheritDoc} */ @Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { pushPath(qName, attributes); if (currPath.toString().equals(xpath)) { inTag = true; data.clear(); for (int i = 0; i < attributes.getLength(); i++) { String name = attributes.getLocalName(i); if (StringUtils.isEmpty(name)) name = attributes.getQName(i); data.put(name, attributes.getValue(i)); } } else { currentElement = qName; } inElement = true; sbData.setLength(0); } /** * Push a path element from the stack * * @param qName element name to push * @param att attributes */ private void pushPath(String qName, Attributes att) { if (att.getLength() > 0 && queryAttributes.containsKey(qName)) { String curr = qName + "["; boolean first = true; final List<String> attList = queryAttributes.get(qName); for (int i = 0; i < att.getLength(); i++) { if (!attList.contains(att.getQName(i))) continue; if (first) first = false; else curr += ','; curr += "@" + att.getQName(i) + "='" + att.getValue(i) + "'"; } curr += ']'; path.add(curr); } else path.add(qName); buildPath(); } /** * Pop the top path element from the stack */ private void popPath() { path.remove(path.size() - 1); buildPath(); } /** * Rebuild the current path */ private synchronized void buildPath() { currPath.setLength(0); for (String s : path) currPath.append(s).append('/'); if (currPath.length() > 1) currPath.delete(currPath.length() - 1, currPath.length()); // System.out.println("currPath: " + currPath); } /** * {@inheritDoc} */ @Override public void endElement(String uri, String localName, String qName) throws SAXException { if (currPath.toString().equals(xpath)) { if (DBG) LOG.info("Insert [" + xpath + "]: [" + data + "]"); inTag = false; try { if (insertMode) { if (executeInsertPhase) { processColumnSet(insertColumns, psInsert); counter += psInsert.executeUpdate(); } } else { if (executeUpdatePhase) { if (processColumnSet(updateSetColumns, psUpdate)) { processColumnSet(updateClauseColumns, psUpdate); counter += psUpdate.executeUpdate(); } } } } catch (SQLException e) { throw new SAXException(e); } catch (ParseException e) { throw new SAXException(e); } } else { if (inTag) { data.put(currentElement, sbData.toString()); } currentElement = null; } popPath(); inElement = false; sbData.setLength(0); } /** * Process a column set * * @param columns the columns to process * @param ps prepared statement to use * @return if data other than <code>null</code> has been set * @throws SQLException on errors * @throws ParseException on date/time conversion errors */ private boolean processColumnSet(Map<String, ColumnInfo> columns, PreparedStatement ps) throws SQLException, ParseException { boolean dataSet = false; for (String col : columns.keySet()) { ColumnInfo ci = columns.get(col); String value = data.get(col); if (insertMode && counters != null && counters.get(col) != null) { final int newVal = counters.get(col) - 1; value = String.valueOf(newVal); counters.put(col, newVal); // System.out.println("new value for " + col + ": " + newVal); } if (insertMode && presetRefColumns != null && presetRefColumns.get(col) != null) { value = data.get(presetRefColumns.get(col)); // System.out.println("Set presetRefColumn for "+col+" to ["+value+"] from column ["+presetRefColumns.get(col)+"]"); } if (value == null) ps.setNull(ci.index, ci.columnType); else { dataSet = true; switch (ci.columnType) { case Types.BIGINT: case Types.NUMERIC: if (DBG) LOG.info("BigInt " + ci.index + "->" + new BigDecimal(value)); ps.setBigDecimal(ci.index, new BigDecimal(value)); break; case java.sql.Types.DOUBLE: if (DBG) LOG.info("Double " + ci.index + "->" + Double.parseDouble(value)); ps.setDouble(ci.index, Double.parseDouble(value)); break; case java.sql.Types.FLOAT: case java.sql.Types.REAL: if (DBG) LOG.info("Float " + ci.index + "->" + Float.parseFloat(value)); ps.setFloat(ci.index, Float.parseFloat(value)); break; case java.sql.Types.TIMESTAMP: case java.sql.Types.DATE: if (DBG) LOG.info("Timestamp/Date " + ci.index + "->" + FxFormatUtils.getDateTimeFormat().parse(value)); ps.setTimestamp(ci.index, new Timestamp(FxFormatUtils.getDateTimeFormat().parse(value).getTime())); break; case Types.TINYINT: case Types.SMALLINT: if (DBG) LOG.info("Integer " + ci.index + "->" + Integer.valueOf(value)); ps.setInt(ci.index, Integer.valueOf(value)); break; case Types.INTEGER: case Types.DECIMAL: try { if (DBG) LOG.info("Long " + ci.index + "->" + Long.valueOf(value)); ps.setLong(ci.index, Long.valueOf(value)); } catch (NumberFormatException e) { //Fallback (temporary) for H2 if the reported long is a big decimal (tree...) ps.setBigDecimal(ci.index, new BigDecimal(value)); } break; case Types.BIT: case Types.CHAR: case Types.BOOLEAN: if (DBG) LOG.info("Boolean " + ci.index + "->" + value); if ("1".equals(value) || "true".equals(value)) ps.setBoolean(ci.index, true); else ps.setBoolean(ci.index, false); break; case Types.LONGVARBINARY: case Types.VARBINARY: case Types.BLOB: case Types.BINARY: ZipEntry bin = zip.getEntry(value); if (bin == null) { LOG.error("Failed to lookup binary [" + value + "]!"); ps.setNull(ci.index, ci.columnType); break; } try { ps.setBinaryStream(ci.index, zip.getInputStream(bin), (int) bin.getSize()); } catch (IOException e) { LOG.error("IOException importing binary [" + value + "]: " + e.getMessage(), e); } break; case Types.CLOB: case Types.LONGVARCHAR: case Types.VARCHAR: case SQL_LONGNVARCHAR: case SQL_NCHAR: case SQL_NCLOB: case SQL_NVARCHAR: if (DBG) LOG.info("String " + ci.index + "->" + value); ps.setString(ci.index, value); break; default: LOG.warn("Unhandled type [" + ci.columnType + "] for column [" + col + "]"); } } } return dataSet; } /** * {@inheritDoc} */ @Override public void characters(char[] ch, int start, int length) throws SAXException { if (inElement) sbData.append(ch, start, length); } }; handler.processingInstruction("fx_mode", "insert"); parser.parse(zip.getInputStream(ze), handler); if (updateColumns.length > 0 && executeUpdatePhase) { handler.processingInstruction("fx_mode", "update"); parser.parse(zip.getInputStream(ze), handler); } } finally { Database.closeObjects(GenericDivisionImporter.class, psInsert, psUpdate); } }
From source file:org.nuxeo.ecm.core.storage.sql.jdbc.dialect.DialectPostgreSQL.java
@Override public Array createArrayOf(int type, Object[] elements, Connection connection) throws SQLException { if (elements == null || elements.length == 0) { return null; }//from w w w. j a v a 2s .c om String typeName; switch (type) { case Types.VARCHAR: typeName = "varchar"; break; case Types.CLOB: typeName = "text"; break; case Types.BIT: typeName = "bool"; break; case Types.BIGINT: typeName = "int8"; break; case Types.DOUBLE: typeName = "float8"; break; case Types.TIMESTAMP: typeName = "timestamp"; break; case Types.SMALLINT: typeName = "int2"; break; case Types.INTEGER: typeName = "int4"; break; case Types.OTHER: // id switch (idType) { case VARCHAR: typeName = "varchar"; break; case UUID: typeName = "uuid"; break; case SEQUENCE: typeName = "int8"; break; default: throw new AssertionError("Unknown id type: " + idType); } break; default: throw new AssertionError("Unknown type: " + type); } return connection.createArrayOf(typeName, elements); }
From source file:org.intermine.web.struts.InitialiserPlugin.java
private boolean verifyTrackTables(ObjectStore uos) { Connection con = null;//from www . ja v a2 s . c om try { con = ((ObjectStoreInterMineImpl) uos).getConnection(); if (DatabaseUtil.tableExists(con, TrackerUtil.TEMPLATE_TRACKER_TABLE)) { ResultSet res = con.getMetaData().getColumns(null, null, TrackerUtil.TEMPLATE_TRACKER_TABLE, "timestamp"); while (res.next()) { if (res.getString(3).equals(TrackerUtil.TEMPLATE_TRACKER_TABLE) && "timestamp".equals(res.getString(4)) && res.getInt(5) == Types.TIMESTAMP) { return true; } return false; } } } catch (SQLException sqle) { LOG.error("Probelm retriving connection", sqle); } finally { ((ObjectStoreInterMineImpl) uos).releaseConnection(con); } return true; }
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 ww. j a va 2 s. c o m*/ }