@Override public long update() throws DataModelException, TMException, SQLException { UserData user = (UserData) datamodel; ResultSet rst = null; try { String sql = UPDATE_USER; Collection<SQLValue> bindVars = new ArrayList<SQLValue>(); bindVars.add(SQLValue.String(user.getUserName())); bindVars.add(SQLValue.String(user.getFirstName())); bindVars.add(SQLValue.String(user.getMiddleName())); bindVars.add(SQLValue.String(user.getLastName())); bindVars.add(SQLValue.String(user.getMailId())); bindVars.add(SQLValue.String(user.getPassword())); bindVars.add(SQLValue.Blob((Blob) user.getImage())); bindVars.add(SQLValue.String(user.getDob())); bindVars.add(SQLValue.Long(user.getSex())); bindVars.add(SQLValue.Long(user.getAddressId())); bindVars.add(SQLValue.String(user.getMaritalStatus())); bindVars.add(SQLValue.String(user.getNationality())); bindVars.add(SQLValue.Boolean(user.isActive())); bindVars.add(SQLValue.String(user.getActivationKey())); bindVars.add(SQLValue.Long(user.getId())); logger.debug("QUERY - Loading Address :" + sql); return executeUpdate(sql, bindVars); } catch (SQLException sql) { logger.error("SQL-Exception", sql); throw new TMException("SQL-Exception", sql.getLocalizedMessage()); } finally { close(null, rst); } }
/** * true if the first result is a ResultSet object; false if the first result is an update count or * there is no result */ public boolean execute(Connection conn, String msql, Object[] params) throws JxException { if (conn == null || msql == null) { throw new JxException("conn or msql is null."); } if (params == null) { Statement st = null; try { st = conn.createStatement(); return st.execute(msql); } catch (SQLException e) { LOG.error(e.getMessage() + "\r\n" + msql); throw new JxException(e.getLocalizedMessage()); } finally { JxDataSourceUtil.closeStatement(st); } } else { PreparedStatement ps = null; try { ps = conn.prepareStatement(msql); for (int i = 0; i < params.length; i++) { ps.setObject(i + 1, params[i]); } return ps.execute(); } catch (SQLException e) { LOG.error(e.getMessage() + "\r\n" + msql); throw new JxException(e.getLocalizedMessage()); } finally { JxDataSourceUtil.closeStatement(ps); } } }
protected boolean beforeSave(boolean newRecord) { // TODO - Think about implement a determination of DocType similar to in MPayment.beforeSave() if (!newRecord) { MPayment[] pays; try { pays = getPayments(get_TrxName()); } catch (SQLException e) { s_log.log(Level.SEVERE, e.getLocalizedMessage(), e); return false; } for (int i = 0; i < pays.length; i++) { pays[i].setC_DocType_ID(getC_DocType_ID()); pays[i].setDocumentNo(getDocumentNo()); pays[i].setDateTrx(getDateTrx()); pays[i].setDateAcct(getDateTrx()); pays[i].setC_BPartner_ID(getC_BPartner_ID()); pays[i].setIsReceipt(isReceipt()); pays[i].setIsActive(isActive()); if (!pays[i].save(get_TrxName())) { try { DB.rollback(false, get_TrxName()); } catch (SQLException e) { s_log.log(Level.SEVERE, e.getLocalizedMessage(), e); } return false; } } } return true; }
private void refreshBasics() { Statement statement = null; try { statement = this.kb.getConnection().createStatement(); StringBuilder sqlString = new StringBuilder("SELECT (name, contenttype, creationtime, contentlength) FROM "); sqlString.append(SQLSharkKB.INFORMATION_TABLE); sqlString.append(" WHERE id = "); sqlString.append(this.id); ResultSet result = statement.executeQuery(sqlString.toString()); if (result.next()) { this.name = result.getString("name"); this.mimetype = result.getString("contenttype"); this.creationTime = result.getLong("creationtime"); this.contentlength = result.getLong("contentlength"); } } catch (SQLException e) { L.w("error while creating SQL-statement: " + e.getLocalizedMessage(), this); } finally { if (statement != null) { try { statement.close(); } catch (SQLException ex) { // ignore } } } }
@Override public void setName(String name) throws SharkKBException { Statement statement = null; this.name = name; try { statement = this.kb.getConnection().createStatement(); StringBuilder sqlString = new StringBuilder("UPDATE "); sqlString.append(SQLSharkKB.INFORMATION_TABLE); sqlString.append(" SET name = '"); sqlString.append(name); long now = System.currentTimeMillis(); sqlString.append("', lastmodifiedtime = "); sqlString.append(now); sqlString.append(" WHERE id = "); sqlString.append(this.id); statement.execute(sqlString.toString()); } catch (SQLException e) { L.e("error while creating SQL-statement: " + e.getLocalizedMessage(), this); } finally { if (statement != null) { try { statement.close(); } catch (SQLException ex) { // ignore } } } }
public void updateCastle(L1Castle castle) { Connection con = null; PreparedStatement pstm = null; try { con = L1DatabaseFactory.getInstance().getConnection(); pstm = con.prepareStatement( "UPDATE castle SET name=?, war_time=?, tax_rate=?, public_money=?, public_ready_money=?, show_money=?, war_basetime=?, security=? WHERE castle_id=?"); pstm.setString(1, castle.getName()); SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); String fm = sdf.format(castle.getWarTime().getTime()); // String fm = DateFormat.getDateTimeInstance().format( //## A1 원본 // castle.getWarTime().getTime()); //# pstm.setString(2, fm); pstm.setInt(3, castle.getTaxRate()); pstm.setInt(4, castle.getPublicMoney()); pstm.setInt(5, castle.getPublicReadyMoney()); pstm.setInt(6, castle.getShowMoney()); pstm.setInt(7, castle.getWarBaseTime()); // String ft = sdf.format(castle.getTimeBase().getTime()); // pstm.setString(8, ft); pstm.setInt(8, castle.getCastleSecurity()); pstm.setInt(9, castle.getId()); pstm.execute(); _castles.put(castle.getId(), castle); } catch (SQLException e) { _log.log(Level.SEVERE, e.getLocalizedMessage(), e); } finally { SQLUtil.close(pstm); SQLUtil.close(con); } }
@Override public DataModel read() throws DataModelException, TMException, SQLException { UserData user = (UserData) datamodel; ResultSet rst = null; try { String sql = READ_USER; Collection<SQLValue> bindVars = new ArrayList<SQLValue>(); if (user.getId() > 0) { sql += AND + "`ID` = ? "; bindVars.add(SQLValue.Long(user.getId())); } if (user.getUserName() != null) { sql += AND + "`USER_NAME` = ? "; bindVars.add(SQLValue.String(user.getUserName())); } if (user.getPassword() != null) { sql += AND + "`PASSWORD` = ? "; bindVars.add(SQLValue.String(user.getPassword())); } logger.debug("QUERY - Loading Address :" + sql); rst = executeQuery(sql, bindVars); return loadUserVO(user, rst); } catch (SQLException sql) { logger.error("SQL-Exception", sql); throw new TMException("SQL-Exception", sql.getLocalizedMessage()); } finally { close(null, rst); } }
@Override public void setUp() { if (!Settings.INSTANCE.getConfig().dataFetcherDBType().equals("postgresql") && !Settings.INSTANCE.getConfig().dataFetcherDBType().equals("mysql")) { String errorMessage = "Wrong parameter provided for database type. " + "Only 'postgresql' and 'mysql' is allowed."; LOG.error(errorMessage); System.err.println(errorMessage); System.exit(1); } type = Settings.INSTANCE.getConfig().dataFetcherDBType(); host = Settings.INSTANCE.getConfig().dataFetcherDBHost(); dbName = Settings.INSTANCE.getConfig().dataFetcherDBName(); user = Settings.INSTANCE.getConfig().dataFetcherDBUser(); password = Settings.INSTANCE.getConfig().dataFetcherDBPassword(); try { connection = connect(); LOG.info("Connection to database succeeded."); } catch (SQLException e) { LOG.error( "An error occured during initialization of the database connection: " + e.getLocalizedMessage()); System.exit(1); } }
/** * 取得报酬 * * @return int 报酬 */ public static int getPay(final int objid) { Connection con = null; PreparedStatement pstm1 = null; PreparedStatement pstm2 = null; ResultSet rs1 = null; int pay = 0; try { con = L1DatabaseFactory.getInstance().getConnection(); pstm1 = con.prepareStatement("SELECT Pay FROM characters WHERE objid = ? FOR UPDATE"); pstm1.setInt(1, objid); rs1 = pstm1.executeQuery(); if (rs1.next()) { pay = rs1.getInt("Pay"); } pstm2 = con.prepareStatement("UPDATE characters SET Pay = 0 WHERE objid = ?"); pstm2.setInt(1, objid); pstm2.execute(); } catch (final SQLException e) { _log.log(Level.SEVERE, e.getLocalizedMessage(), e); } finally { SQLUtil.close(rs1); SQLUtil.close(pstm1); SQLUtil.close(pstm2); SQLUtil.close(con); } return pay; }
/** * BankStmt - Payment. Update Transaction Amount when payment is selected * * @param ctx context * @param WindowNo window no * @param mTab tab * @param mField field * @param value value * @return null or error message */ public String payment( Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value) { Integer C_Payment_ID = (Integer) value; if (C_Payment_ID == null || C_Payment_ID.intValue() == 0) return ""; // BigDecimal stmt = (BigDecimal) mTab.getValue("StmtAmt"); if (stmt == null) stmt = Env.ZERO; String sql = "SELECT PayAmt FROM C_Payment_v WHERE C_Payment_ID=?"; // 1 PreparedStatement pstmt = null; ResultSet rs = null; try { pstmt = DB.prepareStatement(sql, null); pstmt.setInt(1, C_Payment_ID.intValue()); rs = pstmt.executeQuery(); if (rs.next()) { BigDecimal bd = rs.getBigDecimal(1); mTab.setValue("TrxAmt", bd); if (stmt.compareTo(Env.ZERO) == 0) mTab.setValue("StmtAmt", bd); } } catch (SQLException e) { log.log(Level.SEVERE, "BankStmt_Payment", e); return e.getLocalizedMessage(); } finally { DB.close(rs, pstmt); rs = null; pstmt = null; } // Recalculate Amounts amount(ctx, WindowNo, mTab, mField, value); return ""; } // payment
public void load() { Connection con = null; PreparedStatement pstm = null; ResultSet rs = null; _towns.clear(); try { con = L1DatabaseFactory.getInstance().getConnection(); pstm = con.prepareStatement("SELECT * FROM towns"); int townid; rs = pstm.executeQuery(); while (rs.next()) { L1Town town = new L1Town(); townid = rs.getInt("id"); town.setTownId(townid); town.setName(rs.getString("name")); town.setLeaderId(rs.getInt("leader_id")); town.setLeaderName(CharacterTable.getInstance().getCharName(town.getLeaderId())); town.setTaxRate(rs.getInt("tax_rate")); town.setTaxRateReserved(rs.getInt("tax_rate_reserved")); town.setSalesMoney(rs.getInt("sales_money")); town.setSalesMoneyYesterday(rs.getInt("sales_money_yesterday")); town.setTownTax(rs.getInt("town_tax")); town.setTownFixTax(rs.getInt("town_fix_tax")); _towns.put(new Integer(townid), town); } } catch (SQLException e) { _log.log(Level.SEVERE, e.getLocalizedMessage(), e); } finally { SqlUtil.close(rs); SqlUtil.close(pstm); SqlUtil.close(con); } }
public HouseTable() { Connection con = null; PreparedStatement pstm = null; ResultSet rs = null; try { con = L1DatabaseFactory.getInstance().getConnection(); pstm = con.prepareStatement("SELECT * FROM house ORDER BY house_id"); rs = pstm.executeQuery(); L1House house = null; while (rs.next()) { house = new L1House(); house.setHouseId(rs.getInt(1)); house.setHouseName(rs.getString(2)); house.setHouseArea(rs.getInt(3)); house.setLocation(rs.getString(4)); house.setKeeperId(rs.getInt(5)); house.setOnSale(rs.getInt(6) == 1 ? true : false); house.setPurchaseBasement(rs.getInt(7) == 1 ? true : false); house.setTaxDeadline(timestampToCalendar((Timestamp) rs.getObject(8))); _house.put(house.getHouseId(), house); } } catch (SQLException e) { _log.log(Level.SEVERE, e.getLocalizedMessage(), e); } finally { SQLUtil.close(rs); SQLUtil.close(pstm); SQLUtil.close(con); } }
/** * Returns the database product name, from the metadata for a JDBC connection to the default * repository. * * <p>Assumes that the database product name will be the same for the default repository and for * all other repositories to which JDBC connections will be made, through the methods of this * class. * * @return the database product name */ public static String getDatabaseProductName(String dataSourceName, String repositoryName) { if (DBProductName == null) { Connection conn = null; try { conn = getConnection(dataSourceName, repositoryName); DBProductName = conn.getMetaData().getDatabaseProductName(); } catch (Exception e) { if (logger.isTraceEnabled() == true) { logger.trace( String.format( "Could not open a connection. DataSource='%s' DB='%s'.", dataSourceName, repositoryName)); } } finally { try { if (conn != null) { conn.close(); } } catch (SQLException sqle) { logger.debug( "SQL Exception closing statement/connection in getDatabaseProductName: " + sqle.getLocalizedMessage()); } } } return DBProductName; }
public static List<Integer> getHouseIdList() { List<Integer> houseIdList = new ArrayList<Integer>(); Connection con = null; PreparedStatement pstm = null; ResultSet rs = null; try { con = L1DatabaseFactory.getInstance().getConnection(); pstm = con.prepareStatement("SELECT house_id FROM house ORDER BY house_id"); rs = pstm.executeQuery(); while (rs.next()) { int houseId = rs.getInt("house_id"); houseIdList.add(Integer.valueOf(houseId)); } } catch (SQLException e) { _log.log(Level.SEVERE, e.getLocalizedMessage(), e); } finally { SQLUtil.close(rs); SQLUtil.close(pstm); SQLUtil.close(con); } return houseIdList; }
public void updateHouse(L1House house) { Connection con = null; PreparedStatement pstm = null; try { con = L1DatabaseFactory.getInstance().getConnection(); pstm = con.prepareStatement( "UPDATE house SET house_name=?, house_area=?, location=?, keeper_id=?, is_on_sale=?, is_purchase_basement=?, tax_deadline=? WHERE house_id=?"); pstm.setString(1, house.getHouseName()); pstm.setInt(2, house.getHouseArea()); pstm.setString(3, house.getLocation()); pstm.setInt(4, house.getKeeperId()); pstm.setInt(5, house.isOnSale() == true ? 1 : 0); pstm.setInt(6, house.isPurchaseBasement() == true ? 1 : 0); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String fm = formatter.format(house.getTaxDeadline().getTime()); pstm.setString(7, fm); pstm.setInt(8, house.getHouseId()); pstm.execute(); } catch (SQLException e) { _log.log(Level.SEVERE, e.getLocalizedMessage(), e); } finally { SQLUtil.close(pstm); SQLUtil.close(con); } }
private List<Object> readDB(final String sql) { final List<Object> columnList = new ArrayList<>(); try { conn.setAutoCommit(false); try (PreparedStatement stmt = conn.prepareStatement(sql); ResultSet rs = stmt.executeQuery()) { while (rs.next()) { final int columnCount = rs.getMetaData().getColumnCount(); final List<Object> rowList = new ArrayList<>(columnCount); for (int i = 1; i <= columnCount; i++) { rowList.add(rs.getObject(i)); } columnList.add(rowList); } conn.commit(); } catch (final SQLException e) { conn.rollback(); throw e; } finally { conn.setAutoCommit(true); } } catch (final SQLException e1) { jerInfoMsgHandler.showMsg(e1.getLocalizedMessage()); } return columnList; }
@Override public long lastModified() { Statement statement = null; try { statement = this.kb.getConnection().createStatement(); StringBuilder sqlString = new StringBuilder("SELECT (lastmodifiedtime) from "); sqlString.append(SQLSharkKB.INFORMATION_TABLE); sqlString.append(" WHERE id = "); sqlString.append(this.id); ResultSet result = statement.executeQuery(sqlString.toString()); if (result.next()) { return result.getLong(1); } } catch (SQLException e) { L.w("error while creating SQL-statement: " + e.getLocalizedMessage(), this); } finally { if (statement != null) { try { statement.close(); } catch (SQLException ex) { // ignore } } } return 0; }
public synchronized void addSalesMoney(int town_id, int salesMoney) { Connection con = null; PreparedStatement pstm = null; L1Town town = TownTable.getInstance().getTownTable(town_id); int townTaxRate = town.getTaxRate(); int townTax = salesMoney / 100 * townTaxRate; int townFixTax = salesMoney / 100 * 2; if (townTax <= 0 && townTaxRate > 0) { townTax = 1; } if (townFixTax <= 0 && townTaxRate > 0) { townFixTax = 1; } try { con = L1DatabaseFactory.getInstance().getConnection(); pstm = con.prepareStatement( "UPDATE towns SET sales_money = sales_money + ?, town_tax = town_tax + ?, town_fix_tax = town_fix_tax + ? WHERE id = ?"); pstm.setInt(1, salesMoney); pstm.setInt(2, townTax); pstm.setInt(3, townFixTax); pstm.setInt(4, town_id); pstm.execute(); town.setSalesMoney(town.getSalesMoney() + salesMoney); town.setTownTax(town.getTownTax() + townTax); town.setTownFixTax(town.getTownFixTax() + townFixTax); } catch (SQLException e) { _log.log(Level.SEVERE, e.getLocalizedMessage(), e); } finally { SqlUtil.close(pstm); SqlUtil.close(con); } }
/** * Check the schema exists and if not we will use the default schema * * @return * @throws SQLException */ private boolean isOracleSchemaValid() throws SQLException { logger.entering(CLASSNAME, "isOracleSchemaValid"); boolean result = false; Connection conn = null; DatabaseMetaData dbmd = null; ResultSet rs = null; try { conn = getConnectionToDefaultSchema(); dbmd = conn.getMetaData(); rs = dbmd.getSchemas(); while (rs.next()) { String schemaname = rs.getString("TABLE_SCHEM"); if (schema.equalsIgnoreCase(schemaname)) { logger.exiting(CLASSNAME, "isSchemaValid", true); return true; } } } catch (SQLException e) { logger.severe(e.getLocalizedMessage()); throw e; } finally { cleanupConnection(conn, rs, null); } logger.exiting(CLASSNAME, "isOracleSchemaValid", false); return result; }
public static void editBBSThread( MapleClient client, String title, String text, int icon, int localthreadid) { MapleCharacter c = client.getPlayer(); if (c.getGuildId() <= 0) { return; // expelled while viewing? } try { Connection con = DatabaseConnection.getConnection(); PreparedStatement ps = con.prepareStatement( "UPDATE bbs_threads SET " + "`name` = ?, " + "`timestamp` = ?, " + "`icon` = ?, " + "`startpost` = ? " + "WHERE guildid = ? AND localthreadid = ? AND (postercid = ? OR ?)"); ps.setString(1, title); ps.setLong(2, System.currentTimeMillis()); ps.setInt(3, icon); ps.setString(4, text); ps.setInt(5, c.getGuildId()); ps.setInt(6, localthreadid); ps.setInt(7, c.getId()); ps.setBoolean(8, c.getGuildRank() <= 2); ps.execute(); ps.close(); displayThread(client, localthreadid); } catch (SQLException se) { log.error("SQLException: " + se.getLocalizedMessage(), se); } }
public void updatePlayerLastLoggedOut(int playerId) { try { database.UpdatePlayerLastLoggedOut(playerId); } catch (SQLException e) { log.info(e.getLocalizedMessage()); } }
/** * This method is overridden to optimize performance. * * @see * com.metamatrix.modeler.jdbc.data.MethodRequest#performInvocation(com.metamatrix.modeler.jdbc.data.Response) * @since 4.2 */ @Override protected IStatus performInvocation(final Response results) { // Override to optimize ... final DatabaseMetaData dbmd = this.getDatabaseMetaData(); ResultSet resultSet = null; IStatus status = null; try { final String catalogPattern = (String) getParameters()[0]; final String schemaPattern = (String) getParameters()[1]; final String tablePattern = (String) getParameters()[2]; final boolean unique = ((Boolean) getParameters()[3]).booleanValue(); final boolean approximate = ((Boolean) getParameters()[4]).booleanValue(); resultSet = dbmd.getIndexInfo(catalogPattern, schemaPattern, tablePattern, unique, approximate); Response.addResults(results, resultSet, this.isMetadataRequested()); } catch (SQLException e) { status = JdbcUtil.createIStatus(e, e.getLocalizedMessage()); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e1) { } } } return status; }
public String selectCafByNamLogin(String namLogin) { String codDisplaySupplier = null; try { statement = conn.prepareStatement( "SELECT COD_DISPLAY_SUPPLIER FROM USER_SUPPLIER WHERE IDT_PERSON = " + "(SELECT IDT_PERSON FROM USER_ALL WHERE NAM_LOGIN = ?)"); statement.setString(1, namLogin); rs = statement.executeQuery(); if (rs.next()) { codDisplaySupplier = rs.getString("COD_DISPLAY_SUPPLIER"); } else { System.out.println( String.format("Codigo do afiliado não encontrado na tabela USER_SUPPLIER")); } } catch (SQLException e) { System.err.println(e); Assert.fail( String.format( "\n Erro ao tentar deletar evento na AE_EVENT_LOG devido a: %s", e.getLocalizedMessage())); } finally { dbutil.closeResources(statement, rs); } return codDisplaySupplier; }
private void load() { Connection con = null; PreparedStatement pstm = null; ResultSet rs = null; try { con = L1DatabaseFactory.getInstance().getConnection(); pstm = con.prepareStatement("SELECT * FROM castle"); rs = pstm.executeQuery(); L1Castle castle = null; while (rs.next()) { castle = new L1Castle(rs.getInt(1), rs.getString(2)); castle.setWarTime(timestampToCalendar((Timestamp) rs.getObject(3))); castle.setTaxRate(rs.getInt(4)); castle.setPublicMoney(rs.getInt(5)); castle.setPublicReadyMoney(rs.getInt(6)); castle.setShowMoney(rs.getInt(7)); castle.setWarBaseTime(rs.getInt(8)); castle.setCastleSecurity(rs.getInt(9)); // castle.setTimeBase(timestampToCalendar((Timestamp) rs // .getObject(9))); _castles.put(castle.getId(), castle); } } catch (SQLException e) { _log.log(Level.SEVERE, e.getLocalizedMessage(), e); } finally { SQLUtil.close(rs); SQLUtil.close(pstm); SQLUtil.close(con); } }
private void checkConnect() { try { if (conn == null || conn.isClosed()) connect(); } catch (SQLException ex) { System.out.println(ex.getLocalizedMessage()); } }
public UserAccount(long user_id) { this.user_id = user_id; String query = String.format(UserSQL.sqlCreateUserAccountDefault, this.user_id); Connection conn; try { conn = PoolFactory.getPooling().getConnection(); String autogenColumns[] = {"id"}; Statement stm = conn.createStatement(); stm.executeUpdate(query, autogenColumns); ResultSet result_set = stm.getGeneratedKeys(); if (result_set.first()) { this.id = result_set.getLong(1); SpyMemCacheClient.getInstance() .add(String.format(UserAccount.key_UserAccountByUserID, this.user_id), this); } conn.close(); } catch (SQLException e) { System.out.println("SQL Exception Code : " + e.getErrorCode()); System.out.println("SQL Exception Message : " + e.getLocalizedMessage()); e.printStackTrace(); } }
public java.lang.Object[] getSystemMenuItems2Enable(java.lang.String[] menus2enable) { java.lang.Object[] menuList2enable = null; java.util.Vector menuListVector = new java.util.Vector(1, 1); for (int i = 0; i < menus2enable.length; i++) { try { java.sql.Statement stmtDB = connDB.createStatement(); java.sql.ResultSet rSet = stmtDB.executeQuery( "SELECT menu_item FROM menu_item_list WHERE item_desc='" + menus2enable[i] + "' AND app_name = 'hospital_hr'"); while (rSet.next()) { menuListVector.addElement(rSet.getString(1)); } } catch (java.sql.SQLException sqlExec) { javax.swing.JOptionPane.showMessageDialog(this, sqlExec.getLocalizedMessage()); } } return menuList2enable = menuListVector.toArray(); }
public void update() { if (SpyMemCacheClient.getInstance().IsConnected()) SpyMemCacheClient.getInstance() .delete(String.format(UserAccount.key_UserAccountByUserID, this.user_id)); String query = String.format( UserSQL.sqlUpdateUserAccount, this.chips, this.gold, this.experience, this.level, this.lastlogin, this.invitebonus, this.id); System.out.println(query); Connection conn; try { conn = PoolFactory.getPooling().getConnection(); Statement stm = conn.createStatement(); stm.executeUpdate(query); conn.close(); } catch (SQLException e) { System.out.println("SQL Exception Code : " + e.getErrorCode()); System.out.println("SQL Exception Message : " + e.getLocalizedMessage()); e.printStackTrace(); } }
@Override public void setContent(InputStream is, long len) { Statement statement = null; try { StringBuilder sqlString = new StringBuilder("UPDATE "); sqlString.append(SQLSharkKB.INFORMATION_TABLE); sqlString.append(" SET content = (?) WHERE id = "); sqlString.append(this.id); PreparedStatement ps = this.kb.getConnection().prepareStatement(sqlString.toString()); ps.setBinaryStream(1, is, len); ps.executeUpdate(); ps.close(); } catch (SQLException e) { L.e("error while creating SQL-statement: " + e.getLocalizedMessage(), this); } finally { if (statement != null) { try { statement.close(); } catch (SQLException ex) { // ignore } } } this.contentlength = len; }
@Override protected IDBNode[] refetchChildren(FilterConfig fc) { List<ProcedureColumnNode> columns = new ArrayList<ProcedureColumnNode>(); ResultSet rs = JdbcMetaDataProvider.getInstance().getProcedureColumns(schemaName, procedureName, null); if (rs != null) { try { int n = 0; while (rs.next()) { String columnName = rs.getString("COLUMN_NAME"); if (columnName == null) { // if the column name cannot retrieved ,give the unique name for this column n++; columnName = "param" + n; } String mode = Utility.toModeType(rs.getInt("COLUMN_TYPE")); String type = rs.getString("TYPE_NAME"); ProcedureColumnNode column = new ProcedureColumnNode(columnName, type, mode); columns.add(column); } } catch (SQLException e) { logger.log(Level.WARNING, e.getLocalizedMessage(), e); } } return columns.toArray(new ProcedureColumnNode[0]); }