List of usage examples for java.sql ResultSet getShort
short getShort(String columnLabel) throws SQLException;
ResultSet
object as a short
in the Java programming language. From source file:jef.database.DbMetaData.java
private List<Function> innerGetProcedures(String schema, String procdureName) throws SQLException { if (schema == null) { schema = this.schema; }/*from w w w . j av a2 s . co m*/ DatabaseDialect profile = getProfile(); Connection conn = getConnection(false); DatabaseMetaData databaseMetaData = conn.getMetaData(); ResultSet rs = null; try { List<Function> result = new ArrayList<Function>(); rs = databaseMetaData.getProcedures(profile.getCatlog(schema), profile.getSchema(schema), procdureName); while (rs.next()) { Function function = new Function(ObjectType.PROCEDURE); function.setCatalog(rs.getString(1)); function.setSchema(rs.getString(2)); function.setName(rs.getString(3)); function.setRemarks(rs.getString(7)); function.setType(rs.getShort(8)); function.setSpecificName(rs.getString(9)); result.add(function); } return result; } finally { DbUtils.close(rs); releaseConnection(conn); } }
From source file:canreg.client.dataentry.Convert.java
public static boolean convertData(canreg.client.gui.management.CanReg4MigrationInternalFrame.MigrationTask task, String filepath, String datafile, String regcode) { Connection conn;//ww w. ja v a2s .c o m Statement stmt; ResultSet rs_hdr; ResultSet rs_data; boolean success = false; int totalrowcount = 0; int rowsImported = 0; String csv = filepath + Globals.FILE_SEPARATOR + regcode + ".csv"; CSVPrinter printer; try { debugOut("Migrating data " + datafile); pconn = (ParadoxConnection) DriverManager .getConnection("jdbc:paradox:///" + filepath.replaceAll("\\\\", "/")); final ParadoxTable table = TableData.listTables(pconn, datafile).get(0); totalrowcount = table.getRowCount(); SystemDescription sd = new SystemDescription( Globals.CANREG_SERVER_SYSTEM_CONFIG_FOLDER + Globals.FILE_SEPARATOR + regcode + ".xml"); DatabaseVariablesListElement[] variableListElements; variableListElements = sd.getDatabaseVariableListElements(); ArrayList<String> dbvle = new ArrayList(); ArrayList<String> cols = new ArrayList(); // Handling variables names with reservered word by replacing underscore after variable name. for (DatabaseVariablesListElement variable : variableListElements) { if (variable.getShortName().endsWith("_")) { dbvle.add(variable.getShortName().replace("_", "")); } else { dbvle.add(variable.getShortName()); } } conn = DriverManager.getConnection("jdbc:paradox:///" + filepath.replaceAll("\\\\", "/")); final DatabaseMetaData meta = conn.getMetaData(); rs_hdr = meta.getColumns("", "", datafile, "%"); //Comparing variables in file and database while (rs_hdr.next()) { for (String dbvar : dbvle) { if (rs_hdr.getString("COLUMN_NAME").equals(dbvar) || rs_hdr.getString("COLUMN_NAME").replaceAll(" ", "_").equals(dbvar)) { cols.add(rs_hdr.getString("COLUMN_NAME")); } } } String[] strheader = new String[cols.size()]; String query = "SELECT "; for (int i = 0; i < cols.size(); i++) { strheader[i] = cols.get(i).toString(); if (i == cols.size() - 1) { query += "\"" + strheader[i] + "\""; } else { query += "\"" + strheader[i] + "\","; } } query += " FROM \"" + datafile + "\""; CSVFormat format = CSVFormat.DEFAULT.withFirstRecordAsHeader().withHeader(strheader).withDelimiter(','); debugOut(query); printer = new CSVPrinter(new FileWriter(csv), format); int hdrsize = strheader.length; Object[] strdata = new String[hdrsize]; stmt = conn.createStatement(); rs_data = stmt.executeQuery(query); if (Globals.DEBUG) { Statement stmt2 = conn.createStatement(); String q = "SELECT RecNum FROM \"" + datafile + "\""; ResultSet rs_all_data = stmt2.executeQuery(q); debugOut(rs_all_data.toString()); } while (rs_data.next()) { for (int i = 1; i < rs_data.getMetaData().getColumnCount() + 1; i++) { switch (rs_data.getMetaData().getColumnType(i)) { case 4: strdata[i - 1] = Integer.toString(rs_data.getShort(i)); break; case 12: strdata[i - 1] = StringEscapeUtils.escapeCsv(rs_data.getString(i)); break; } } printer.printRecord(strdata); rowsImported++; } printer.flush(); printer.close(); success = true; } catch (SQLException ex) { Logger.getLogger(Convert.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(Convert.class.getName()).log(Level.SEVERE, null, ex); } success = success && (rowsImported == totalrowcount); return success; }
From source file:net.sourceforge.msscodefactory.cfcrm.v2_1.CFCrmDb2LUW.CFCrmDb2LUWContactURLTable.java
protected CFCrmContactURLBuff unpackContactURLResultSetToBuff(ResultSet resultSet) throws SQLException { final String S_ProcName = "unpackContactURLResultSetToBuff"; int idxcol = 1; CFCrmContactURLBuff buff = schema.getFactoryContactURL().newBuff(); {//from w w w. j a va 2 s . c o m String colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setCreatedByUserId(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setCreatedByUserId(null); } else { buff.setCreatedByUserId(UUID.fromString(colString)); } idxcol++; colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setCreatedAt(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setCreatedAt(null); } else { buff.setCreatedAt(CFCrmDb2LUWSchema.convertTimestampString(colString)); } idxcol++; colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setUpdatedByUserId(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setUpdatedByUserId(null); } else { buff.setUpdatedByUserId(UUID.fromString(colString)); } idxcol++; colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setUpdatedAt(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setUpdatedAt(null); } else { buff.setUpdatedAt(CFCrmDb2LUWSchema.convertTimestampString(colString)); } idxcol++; } buff.setRequiredTenantId(resultSet.getLong(idxcol)); idxcol++; buff.setRequiredContactURLId(resultSet.getLong(idxcol)); idxcol++; buff.setRequiredContactId(resultSet.getLong(idxcol)); idxcol++; { short colVal = resultSet.getShort(idxcol); if (resultSet.wasNull()) { buff.setOptionalURLProtocolId(null); } else { buff.setOptionalURLProtocolId(colVal); } } idxcol++; buff.setRequiredName(resultSet.getString(idxcol)); idxcol++; buff.setRequiredURL(resultSet.getString(idxcol)); idxcol++; buff.setRequiredRevision(resultSet.getInt(idxcol)); return (buff); }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccDb2LUW.CFAccDb2LUWContactURLTable.java
protected CFAccContactURLBuff unpackContactURLResultSetToBuff(ResultSet resultSet) throws SQLException { final String S_ProcName = "unpackContactURLResultSetToBuff"; int idxcol = 1; CFAccContactURLBuff buff = schema.getFactoryContactURL().newBuff(); {// www . j a v a2s.c om String colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setCreatedByUserId(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setCreatedByUserId(null); } else { buff.setCreatedByUserId(UUID.fromString(colString)); } idxcol++; colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setCreatedAt(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setCreatedAt(null); } else { buff.setCreatedAt(CFAccDb2LUWSchema.convertTimestampString(colString)); } idxcol++; colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setUpdatedByUserId(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setUpdatedByUserId(null); } else { buff.setUpdatedByUserId(UUID.fromString(colString)); } idxcol++; colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setUpdatedAt(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setUpdatedAt(null); } else { buff.setUpdatedAt(CFAccDb2LUWSchema.convertTimestampString(colString)); } idxcol++; } buff.setRequiredTenantId(resultSet.getLong(idxcol)); idxcol++; buff.setRequiredContactURLId(resultSet.getLong(idxcol)); idxcol++; buff.setRequiredContactId(resultSet.getLong(idxcol)); idxcol++; { short colVal = resultSet.getShort(idxcol); if (resultSet.wasNull()) { buff.setOptionalURLProtocolId(null); } else { buff.setOptionalURLProtocolId(colVal); } } idxcol++; buff.setRequiredName(resultSet.getString(idxcol)); idxcol++; buff.setRequiredURL(resultSet.getString(idxcol)); idxcol++; buff.setRequiredRevision(resultSet.getInt(idxcol)); return (buff); }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccPgSql.CFAccPgSqlContactURLTable.java
protected CFAccContactURLBuff unpackContactURLResultSetToBuff(ResultSet resultSet) throws SQLException { final String S_ProcName = "unpackContactURLResultSetToBuff"; int idxcol = 1; CFAccContactURLBuff buff = schema.getFactoryContactURL().newBuff(); {//from w ww . j a va 2 s. co m String colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setCreatedByUserId(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setCreatedByUserId(null); } else { buff.setCreatedByUserId(UUID.fromString(colString)); } idxcol++; colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setCreatedAt(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setCreatedAt(null); } else { buff.setCreatedAt(CFAccPgSqlSchema.convertTimestampString(colString)); } idxcol++; colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setUpdatedByUserId(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setUpdatedByUserId(null); } else { buff.setUpdatedByUserId(UUID.fromString(colString)); } idxcol++; colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setUpdatedAt(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setUpdatedAt(null); } else { buff.setUpdatedAt(CFAccPgSqlSchema.convertTimestampString(colString)); } idxcol++; } buff.setRequiredTenantId(resultSet.getLong(idxcol)); idxcol++; buff.setRequiredContactURLId(resultSet.getLong(idxcol)); idxcol++; buff.setRequiredContactId(resultSet.getLong(idxcol)); idxcol++; { short colVal = resultSet.getShort(idxcol); if (resultSet.wasNull()) { buff.setOptionalURLProtocolId(null); } else { buff.setOptionalURLProtocolId(colVal); } } idxcol++; buff.setRequiredName(resultSet.getString(idxcol)); idxcol++; buff.setRequiredURL(resultSet.getString(idxcol)); idxcol++; buff.setRequiredRevision(resultSet.getInt(idxcol)); return (buff); }
From source file:net.sourceforge.msscodefactory.cfcrm.v2_1.CFCrmMSSql.CFCrmMSSqlContactURLTable.java
protected CFCrmContactURLBuff unpackContactURLResultSetToBuff(ResultSet resultSet) throws SQLException { final String S_ProcName = "unpackContactURLResultSetToBuff"; int idxcol = 1; CFCrmContactURLBuff buff = schema.getFactoryContactURL().newBuff(); {/*from w ww .j a v a2s. c o m*/ String colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setCreatedByUserId(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setCreatedByUserId(null); } else { buff.setCreatedByUserId(UUID.fromString(colString)); } idxcol++; colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setCreatedAt(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setCreatedAt(null); } else { buff.setCreatedAt(CFCrmMSSqlSchema.convertTimestampString(colString)); } idxcol++; colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setUpdatedByUserId(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setUpdatedByUserId(null); } else { buff.setUpdatedByUserId(UUID.fromString(colString)); } idxcol++; colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setUpdatedAt(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setUpdatedAt(null); } else { buff.setUpdatedAt(CFCrmMSSqlSchema.convertTimestampString(colString)); } idxcol++; } buff.setRequiredTenantId(resultSet.getLong(idxcol)); idxcol++; buff.setRequiredContactURLId(resultSet.getLong(idxcol)); idxcol++; buff.setRequiredContactId(resultSet.getLong(idxcol)); idxcol++; { short colVal = resultSet.getShort(idxcol); if (resultSet.wasNull()) { buff.setOptionalURLProtocolId(null); } else { buff.setOptionalURLProtocolId(colVal); } } idxcol++; buff.setRequiredName(resultSet.getString(idxcol)); idxcol++; buff.setRequiredURL(resultSet.getString(idxcol)); idxcol++; buff.setRequiredRevision(resultSet.getInt(idxcol)); return (buff); }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccMSSql.CFAccMSSqlContactURLTable.java
protected CFAccContactURLBuff unpackContactURLResultSetToBuff(ResultSet resultSet) throws SQLException { final String S_ProcName = "unpackContactURLResultSetToBuff"; int idxcol = 1; CFAccContactURLBuff buff = schema.getFactoryContactURL().newBuff(); {/*from ww w . j av a2 s . c o m*/ String colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setCreatedByUserId(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setCreatedByUserId(null); } else { buff.setCreatedByUserId(UUID.fromString(colString)); } idxcol++; colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setCreatedAt(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setCreatedAt(null); } else { buff.setCreatedAt(CFAccMSSqlSchema.convertTimestampString(colString)); } idxcol++; colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setUpdatedByUserId(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setUpdatedByUserId(null); } else { buff.setUpdatedByUserId(UUID.fromString(colString)); } idxcol++; colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setUpdatedAt(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setUpdatedAt(null); } else { buff.setUpdatedAt(CFAccMSSqlSchema.convertTimestampString(colString)); } idxcol++; } buff.setRequiredTenantId(resultSet.getLong(idxcol)); idxcol++; buff.setRequiredContactURLId(resultSet.getLong(idxcol)); idxcol++; buff.setRequiredContactId(resultSet.getLong(idxcol)); idxcol++; { short colVal = resultSet.getShort(idxcol); if (resultSet.wasNull()) { buff.setOptionalURLProtocolId(null); } else { buff.setOptionalURLProtocolId(colVal); } } idxcol++; buff.setRequiredName(resultSet.getString(idxcol)); idxcol++; buff.setRequiredURL(resultSet.getString(idxcol)); idxcol++; buff.setRequiredRevision(resultSet.getInt(idxcol)); return (buff); }
From source file:net.sourceforge.msscodefactory.cfcrm.v2_1.CFCrmMySql.CFCrmMySqlContactURLTable.java
protected CFCrmContactURLBuff unpackContactURLResultSetToBuff(ResultSet resultSet) throws SQLException { final String S_ProcName = "unpackContactURLResultSetToBuff"; int idxcol = 1; CFCrmContactURLBuff buff = schema.getFactoryContactURL().newBuff(); {/*from w w w . ja v a2s . c o m*/ String colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setCreatedAt(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setCreatedAt(null); } else { buff.setCreatedAt(CFCrmMySqlSchema.convertTimestampString(colString)); } } idxcol++; { String colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setCreatedByUserId(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setCreatedByUserId(null); } else { buff.setCreatedByUserId(UUID.fromString(colString)); } } idxcol++; { String colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setUpdatedAt(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setUpdatedAt(null); } else { buff.setUpdatedAt(CFCrmMySqlSchema.convertTimestampString(colString)); } } idxcol++; { String colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setUpdatedByUserId(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setUpdatedByUserId(null); } else { buff.setUpdatedByUserId(UUID.fromString(colString)); } } idxcol++; buff.setRequiredTenantId(resultSet.getLong(idxcol)); idxcol++; buff.setRequiredContactURLId(resultSet.getLong(idxcol)); idxcol++; buff.setRequiredContactId(resultSet.getLong(idxcol)); idxcol++; { short colVal = resultSet.getShort(idxcol); if (resultSet.wasNull()) { buff.setOptionalURLProtocolId(null); } else { buff.setOptionalURLProtocolId(colVal); } } idxcol++; buff.setRequiredName(resultSet.getString(idxcol)); idxcol++; buff.setRequiredURL(resultSet.getString(idxcol)); idxcol++; buff.setRequiredRevision(resultSet.getInt(idxcol)); return (buff); }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccMySql.CFAccMySqlContactURLTable.java
protected CFAccContactURLBuff unpackContactURLResultSetToBuff(ResultSet resultSet) throws SQLException { final String S_ProcName = "unpackContactURLResultSetToBuff"; int idxcol = 1; CFAccContactURLBuff buff = schema.getFactoryContactURL().newBuff(); {/* ww w .j a v a 2s. c o m*/ String colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setCreatedAt(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setCreatedAt(null); } else { buff.setCreatedAt(CFAccMySqlSchema.convertTimestampString(colString)); } } idxcol++; { String colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setCreatedByUserId(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setCreatedByUserId(null); } else { buff.setCreatedByUserId(UUID.fromString(colString)); } } idxcol++; { String colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setUpdatedAt(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setUpdatedAt(null); } else { buff.setUpdatedAt(CFAccMySqlSchema.convertTimestampString(colString)); } } idxcol++; { String colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setUpdatedByUserId(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setUpdatedByUserId(null); } else { buff.setUpdatedByUserId(UUID.fromString(colString)); } } idxcol++; buff.setRequiredTenantId(resultSet.getLong(idxcol)); idxcol++; buff.setRequiredContactURLId(resultSet.getLong(idxcol)); idxcol++; buff.setRequiredContactId(resultSet.getLong(idxcol)); idxcol++; { short colVal = resultSet.getShort(idxcol); if (resultSet.wasNull()) { buff.setOptionalURLProtocolId(null); } else { buff.setOptionalURLProtocolId(colVal); } } idxcol++; buff.setRequiredName(resultSet.getString(idxcol)); idxcol++; buff.setRequiredURL(resultSet.getString(idxcol)); idxcol++; buff.setRequiredRevision(resultSet.getInt(idxcol)); return (buff); }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccDb2LUW.CFAccDb2LUWAccountTable.java
protected CFAccAccountBuff unpackAccountResultSetToBuff(ResultSet resultSet) throws SQLException { final String S_ProcName = "unpackAccountResultSetToBuff"; int idxcol = 1; CFAccAccountBuff buff = schema.getFactoryAccount().newBuff(); {/*ww w .j av a2 s . c o m*/ String colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setCreatedByUserId(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setCreatedByUserId(null); } else { buff.setCreatedByUserId(UUID.fromString(colString)); } idxcol++; colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setCreatedAt(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setCreatedAt(null); } else { buff.setCreatedAt(CFAccDb2LUWSchema.convertTimestampString(colString)); } idxcol++; colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setUpdatedByUserId(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setUpdatedByUserId(null); } else { buff.setUpdatedByUserId(UUID.fromString(colString)); } idxcol++; colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setUpdatedAt(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setUpdatedAt(null); } else { buff.setUpdatedAt(CFAccDb2LUWSchema.convertTimestampString(colString)); } idxcol++; } buff.setRequiredTenantId(resultSet.getLong(idxcol)); idxcol++; buff.setRequiredId(resultSet.getLong(idxcol)); idxcol++; buff.setRequiredAccountCode(resultSet.getString(idxcol)); idxcol++; buff.setRequiredDescription(resultSet.getString(idxcol)); idxcol++; buff.setRequiredCurrencyId(resultSet.getShort(idxcol)); idxcol++; buff.setRequiredBalance(resultSet.getBigDecimal(idxcol)); idxcol++; { long colVal = resultSet.getLong(idxcol); if (resultSet.wasNull()) { buff.setOptionalRollupTenantId(null); } else { buff.setOptionalRollupTenantId(colVal); } } idxcol++; { long colVal = resultSet.getLong(idxcol); if (resultSet.wasNull()) { buff.setOptionalRollupAccountId(null); } else { buff.setOptionalRollupAccountId(colVal); } } idxcol++; buff.setRequiredRevision(resultSet.getInt(idxcol)); return (buff); }