List of usage examples for java.sql ResultSet TYPE_SCROLL_INSENSITIVE
int TYPE_SCROLL_INSENSITIVE
To view the source code for java.sql ResultSet TYPE_SCROLL_INSENSITIVE.
Click Source Link
ResultSet
object that is scrollable but generally not sensitive to changes to the data that underlies the ResultSet
. From source file:Main.java
public static void showProperty(ResultSet rset) throws SQLException { switch (rset.getType()) { case ResultSet.TYPE_FORWARD_ONLY: System.out.println("Result set type: TYPE_FORWARD_ONLY"); break;/* w w w. j a v a 2 s .co m*/ case ResultSet.TYPE_SCROLL_INSENSITIVE: System.out.println("Result set type: TYPE_SCROLL_INSENSITIVE"); break; case ResultSet.TYPE_SCROLL_SENSITIVE: System.out.println("Result set type: TYPE_SCROLL_SENSITIVE"); break; default: System.out.println("Invalid type"); break; } switch (rset.getConcurrency()) { case ResultSet.CONCUR_UPDATABLE: System.out.println("Result set concurrency: ResultSet.CONCUR_UPDATABLE"); break; case ResultSet.CONCUR_READ_ONLY: System.out.println("Result set concurrency: ResultSet.CONCUR_READ_ONLY"); break; default: System.out.println("Invalid type"); break; } System.out.println("fetch size: " + rset.getFetchSize()); }
From source file:Connexion.Charts.java
public Charts() { try {/*from w w w. j a v a 2 s . co m*/ Class.forName("com.mysql.jdbc.Driver"); } catch (ClassNotFoundException e) { /* Grer les ventuelles erreurs ici. */ } int a = 0; int b = 0; int c = 0; try { ResultSet resultat1 = this.connect .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE) .executeQuery("SELECT code_service FROM hospitalisation WHERE code_service = 'REA'"); // on rcupre le nombre de lignes de la requte if (resultat1.last()) { a = resultat1.getRow(); } System.out.println(a); } catch (SQLException e) { e.printStackTrace(); } try { ResultSet resultat2 = this.connect .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE) .executeQuery("SELECT code_service FROM hospitalisation WHERE code_service = 'CHG'"); // on rcupre le nombre de lignes de la requte if (resultat2.last()) { b = resultat2.getRow(); } System.out.println(b); } catch (SQLException e) { e.printStackTrace(); } try { ResultSet resultat3 = this.connect .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE) .executeQuery("SELECT code_service FROM hospitalisation WHERE code_service = 'CAR'"); // on rcupre le nombre de lignes de la requte if (resultat3.last()) { c = resultat3.getRow(); } } catch (SQLException e) { e.printStackTrace(); } DefaultPieDataset union = new DefaultPieDataset(); //remplir l'ensemble union.setValue("REA", a); union.setValue("CAR", b); union.setValue("CHG", c); JFreeChart repart = ChartFactory.createPieChart3D("Nombre d'hospitalisation par service", union, true, true, false); ChartPanel crepart = new ChartPanel(repart); this.add(crepart); this.pack(); this.setVisible(true); }
From source file:Transaction.java
public void doWork() { try {// w ww . ja va 2 s .co m java.util.Date now = new java.util.Date(); connection.setAutoCommit(false); Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); ResultSet rs = statement.executeQuery("SELECT * FROM acc_add WHERE acc_id = 1034055 and ts = 0"); // set old row ts = current time rs.next(); rs.updateTimestamp("ts", new Timestamp(now.getTime())); rs.updateRow(); rs.moveToInsertRow(); rs.updateInt("add_id", rs.getInt("add_id")); rs.updateInt("acc_id", rs.getInt("acc_id")); rs.updateString("name", rs.getString("name")); rs.updateString("address1", "555 East South Street"); rs.updateString("address2", ""); rs.updateString("address3", ""); rs.updateString("city", rs.getString("city")); rs.updateString("state", rs.getString("state")); rs.updateString("zip", rs.getString("zip")); rs.updateTimestamp("ts", new Timestamp(0)); rs.updateTimestamp("act_ts", new Timestamp(now.getTime())); rs.insertRow(); connection.commit(); rs.close(); statement.close(); connection.close(); } catch (Exception e) { try { connection.rollback(); } catch (SQLException error) { } e.printStackTrace(); } }
From source file:Connexion.ChartDocteur.java
public ChartDocteur() { try {//from w w w. ja v a2 s . c o m Class.forName("com.mysql.jdbc.Driver"); } catch (ClassNotFoundException e) { /* Grer les ventuelles erreurs ici. */ } int a = 0; int b = 0; int c = 0; int d = 0; int f = 0; int g = 0; try { ResultSet resultat1 = this.connect .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE) .executeQuery("SELECT specialite FROM docteur WHERE specialite = 'Cardiologue'"); // on rcupre le nombre de lignes de la requte if (resultat1.last()) { a = resultat1.getRow(); } System.out.println(a); } catch (SQLException e) { e.printStackTrace(); } try { ResultSet resultat2 = this.connect .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE) .executeQuery("SELECT specialite FROM docteur WHERE specialite = 'Traumatologue'"); // on rcupre le nombre de lignes de la requte if (resultat2.last()) { b = resultat2.getRow(); } System.out.println(b); } catch (SQLException e) { e.printStackTrace(); } try { ResultSet resultat3 = this.connect .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE) .executeQuery("SELECT specialite FROM docteur WHERE specialite = 'Pneumologue'"); // on rcupre le nombre de lignes de la requte if (resultat3.last()) { c = resultat3.getRow(); } System.out.println(c); } catch (SQLException e) { e.printStackTrace(); } try { ResultSet resultat4 = this.connect .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE) .executeQuery("SELECT specialite FROM docteur WHERE specialite = 'Orthopediste'"); // on rcupre le nombre de lignes de la requte if (resultat4.last()) { d = resultat4.getRow(); } System.out.println(d); } catch (SQLException e) { e.printStackTrace(); } try { ResultSet resultat5 = this.connect .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE) .executeQuery("SELECT specialite FROM docteur WHERE specialite = 'Radiologue'"); // on rcupre le nombre de lignes de la requte if (resultat5.last()) { f = resultat5.getRow(); } System.out.println(f); } catch (SQLException e) { e.printStackTrace(); } try { ResultSet resultat6 = this.connect .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE) .executeQuery("SELECT specialite FROM docteur WHERE specialite = 'Anesthesiste'"); // on rcupre le nombre de lignes de la requte if (resultat6.last()) { g = resultat6.getRow(); } System.out.println(g); } catch (SQLException e) { e.printStackTrace(); } DefaultPieDataset union = new DefaultPieDataset(); //remplir l'ensemble union.setValue("Cardiologue", a); union.setValue("Traumatologue", b); union.setValue("Pneumologue", c); union.setValue("Orthopediste", d); union.setValue("Radiologue", f); union.setValue("Anesthesiste", g); JFreeChart repart = ChartFactory.createPieChart3D("Nombre de mdecin par spcialit", union, true, true, false); ChartPanel crepart = new ChartPanel(repart); this.add(crepart); this.pack(); this.setVisible(true); }
From source file:Connexion.ChartMutuelle.java
public ChartMutuelle() { try {//from ww w. j a v a 2 s. c o m Class.forName("com.mysql.jdbc.Driver"); } catch (ClassNotFoundException e) { /* Grer les ventuelles erreurs ici. */ } int ag2r = 0; int ccvrp = 0; int cnamts = 0; int lmde = 0; int maaf = 0; int mas = 0; int mgen = 0; int mgsp = 0; int mma = 0; int mnam = 0; int mnftc = 0; int mnh = 0; try { ResultSet resultat1 = this.connect .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE) .executeQuery("SELECT mutuelle FROM malade WHERE mutuelle = 'AG2R'"); // on rcupre le nombre de lignes de la requte if (resultat1.last()) { ag2r = resultat1.getRow(); } System.out.println(ag2r); } catch (SQLException e) { e.printStackTrace(); } try { ResultSet resultat2 = this.connect .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE) .executeQuery("SELECT mutuelle FROM malade WHERE mutuelle = 'CCVRP'"); // on rcupre le nombre de lignes de la requte if (resultat2.last()) { ccvrp = resultat2.getRow(); } System.out.println(ccvrp); } catch (SQLException e) { e.printStackTrace(); } try { ResultSet resultat3 = this.connect .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE) .executeQuery("SELECT mutuelle FROM malade WHERE mutuelle = 'CNAMTS'"); // on rcupre le nombre de lignes de la requte if (resultat3.last()) { cnamts = resultat3.getRow(); } System.out.println(cnamts); } catch (SQLException e) { e.printStackTrace(); } try { ResultSet resultat4 = this.connect .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE) .executeQuery("SELECT mutuelle FROM malade WHERE mutuelle = 'LMDE'"); // on rcupre le nombre de lignes de la requte if (resultat4.last()) { lmde = resultat4.getRow(); } System.out.println(lmde); } catch (SQLException e) { e.printStackTrace(); } try { ResultSet resultat5 = this.connect .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE) .executeQuery("SELECT mutuelle FROM malade WHERE mutuelle = 'MAAF'"); // on rcupre le nombre de lignes de la requte if (resultat5.last()) { maaf = resultat5.getRow(); } System.out.println(maaf); } catch (SQLException e) { e.printStackTrace(); } try { ResultSet resultat6 = this.connect .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE) .executeQuery("SELECT mutuelle FROM malade WHERE mutuelle = 'MAS'"); // on rcupre le nombre de lignes de la requte if (resultat6.last()) { mas = resultat6.getRow(); } System.out.println(mas); } catch (SQLException e) { e.printStackTrace(); } try { ResultSet resultat7 = this.connect .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE) .executeQuery("SELECT mutuelle FROM malade WHERE mutuelle = 'MGEN'"); // on rcupre le nombre de lignes de la requte if (resultat7.last()) { mgen = resultat7.getRow(); } System.out.println(mgen); } catch (SQLException e) { e.printStackTrace(); } try { ResultSet resultat8 = this.connect .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE) .executeQuery("SELECT mutuelle FROM malade WHERE mutuelle = 'MGSP'"); // on rcupre le nombre de lignes de la requte if (resultat8.last()) { mgsp = resultat8.getRow(); } System.out.println(mgsp); } catch (SQLException e) { e.printStackTrace(); } try { ResultSet resultat9 = this.connect .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE) .executeQuery("SELECT mutuelle FROM malade WHERE mutuelle = 'MMA'"); // on rcupre le nombre de lignes de la requte if (resultat9.last()) { mma = resultat9.getRow(); } System.out.println(mma); } catch (SQLException e) { e.printStackTrace(); } try { ResultSet resultat10 = this.connect .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE) .executeQuery("SELECT mutuelle FROM malade WHERE mutuelle = 'MNAM'"); // on rcupre le nombre de lignes de la requte if (resultat10.last()) { mnam = resultat10.getRow(); } System.out.println(mnam); } catch (SQLException e) { e.printStackTrace(); } try { ResultSet resultat11 = this.connect .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE) .executeQuery("SELECT mutuelle FROM malade WHERE mutuelle = 'MNFTC'"); // on rcupre le nombre de lignes de la requte if (resultat11.last()) { mnftc = resultat11.getRow(); } System.out.println(mnftc); } catch (SQLException e) { e.printStackTrace(); } try { ResultSet resultat12 = this.connect .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE) .executeQuery("SELECT mutuelle FROM malade WHERE mutuelle = 'MNH'"); // on rcupre le nombre de lignes de la requte if (resultat12.last()) { mnh = resultat12.getRow(); } System.out.println(mnh); } catch (SQLException e) { e.printStackTrace(); } DefaultPieDataset union = new DefaultPieDataset(); //remplir l'ensemble union.setValue("AG2R", ag2r); union.setValue("CCVRP", ccvrp); union.setValue("CNAMTS", cnamts); union.setValue("LMDE", lmde); union.setValue("MAAD", maaf); union.setValue("MAS", mas); union.setValue("MGEN", mgen); union.setValue("MGSP", mgsp); union.setValue("MMA", mma); union.setValue("MNAM", mnam); union.setValue("MNFTC", mnftc); union.setValue("MNH", mnh); JFreeChart repart = ChartFactory.createPieChart3D("Nombre de malades par mutuelle", union, true, true, false); ChartPanel crepart = new ChartPanel(repart); this.add(crepart); this.pack(); this.setVisible(true); }
From source file:com.adaptris.jdbc.JdbcResultSetImpl.java
@Override public Iterable<JdbcResultRow> getRows() { return new Iterable<JdbcResultRow>() { @Override//from w ww. j a v a 2 s .c o m public Iterator<JdbcResultRow> iterator() { try { switch (resultSet.getType()) { case ResultSet.TYPE_FORWARD_ONLY: return new ForwardOnlyResultSetIterator(resultSet); case ResultSet.TYPE_SCROLL_SENSITIVE: case ResultSet.TYPE_SCROLL_INSENSITIVE: return new ScrollableResultSetIterator(resultSet); default: throw new RuntimeException("ResultSet was of unknown type"); } } catch (SQLException e) { throw new RuntimeException(e); } } }; }
From source file:com.itdaoshi.discuz.dao.CdbUcMembersDAObject.java
protected synchronized Object insertDB(Object obj1) { PreparedStatement preStat = null; StringBuffer sqlStat = new StringBuffer(); CdbUcMembers obj = (CdbUcMembers) obj1; synchronized (conn) { try {//w w w . ja va2 s . c o m Long nextID = getNextPrimaryID(); // Integer nextID = 2; sqlStat.append("INSERT "); sqlStat.append( "INTO CDB_UC_MEMBERS(uid, username, password, email, myid, myidkey, regip, regdate, lastloginip, lastlogintime, salt, secques) "); sqlStat.append("VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) "); preStat = conn.prepareStatement(sqlStat.toString(), ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); setPrepareStatement(preStat, 1, nextID); setPrepareStatement(preStat, 2, obj.getUsername()); setPrepareStatement(preStat, 3, obj.getPassword()); setPrepareStatement(preStat, 4, obj.getEmail()); setPrepareStatement(preStat, 5, obj.getMyid()); setPrepareStatement(preStat, 6, obj.getMyidkey()); setPrepareStatement(preStat, 7, obj.getRegip()); setPrepareStatement(preStat, 8, obj.getRegdate()); setPrepareStatement(preStat, 9, obj.getLastloginip()); setPrepareStatement(preStat, 10, obj.getLastlogintime()); setPrepareStatement(preStat, 11, obj.getSalt()); setPrepareStatement(preStat, 12, obj.getSecques()); preStat.executeUpdate(); return obj; } catch (Exception Ex) { Ex.printStackTrace(); } finally { try { preStat.close(); } catch (Exception ignore) { } finally { preStat = null; } } } return obj; }
From source file:de.static_interface.reallifeplugin.database.AbstractTable.java
public T[] get(String query, Object... paramObjects) throws SQLException { query = query.replaceAll("\\Q{TABLE}\\E", getName()); PreparedStatement statement = db.getConnection().prepareStatement(query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); if (paramObjects != null && paramObjects.length > 0) { int i = 1; for (Object s : paramObjects) { statement.setObject(i, s);//from w w w. ja v a 2 s . com i++; } } return deserialize(statement.executeQuery()); }
From source file:DbManager.java
/** * Initialize a generic DbManager.// w w w . j av a 2s.co m * * @param driver * the driver. * @param database * the database name. * @param login * the login. * @param passwd * the password. */ public DbManager(String driver, String database, String login, String passwd) { dbArray = false; try { initDb(driver, database, login, passwd); stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.itdaoshi.dokeos.dao.UserDAObject.java
protected synchronized User insert(User obj) { PreparedStatement preStat = null; StringBuffer sqlStat = new StringBuffer(); synchronized (conn) { try {/*from www . ja v a 2s. c o m*/ Long nextID = getNextPrimaryID(); sqlStat.append("INSERT "); sqlStat.append( "INTO USER(user_id, lastname, firstname, username, password, auth_source, email, status, official_code, phone, picture_uri, creator_id, competences, diplomas, openarea, teach, productions, chatcall_user_id, chatcall_date, chatcall_text, language, registration_date, expiration_date, active, openid, theme, hr_dept_id) "); sqlStat.append( "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) "); preStat = conn.prepareStatement(sqlStat.toString(), ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); setPrepareStatement(preStat, 1, nextID); setPrepareStatement(preStat, 2, obj.getLastname()); setPrepareStatement(preStat, 3, obj.getFirstname()); setPrepareStatement(preStat, 4, obj.getUsername()); setPrepareStatement(preStat, 5, obj.getPassword()); setPrepareStatement(preStat, 6, obj.getAuthSource()); setPrepareStatement(preStat, 7, obj.getEmail()); setPrepareStatement(preStat, 8, obj.getStatus()); setPrepareStatement(preStat, 9, obj.getOfficialCode()); setPrepareStatement(preStat, 10, obj.getPhone()); setPrepareStatement(preStat, 11, obj.getPictureUri()); setPrepareStatement(preStat, 12, obj.getCreatorID()); setPrepareStatement(preStat, 13, obj.getCompetences()); setPrepareStatement(preStat, 14, obj.getDiplomas()); setPrepareStatement(preStat, 15, obj.getOpenarea()); setPrepareStatement(preStat, 16, obj.getTeach()); setPrepareStatement(preStat, 17, obj.getProductions()); setPrepareStatement(preStat, 18, obj.getChatcallUserID()); setPrepareStatement(preStat, 19, obj.getChatcallDate()); setPrepareStatement(preStat, 20, obj.getChatcallText()); setPrepareStatement(preStat, 21, obj.getLanguage()); setPrepareStatement(preStat, 22, obj.getRegistrationDate()); setPrepareStatement(preStat, 23, obj.getExpirationDate()); setPrepareStatement(preStat, 24, obj.getActive()); setPrepareStatement(preStat, 25, obj.getOpenid()); setPrepareStatement(preStat, 26, obj.getTheme()); setPrepareStatement(preStat, 27, obj.getHrDeptID()); preStat.executeUpdate(); return obj; } catch (Exception Ex) { Ex.printStackTrace(); } finally { try { preStat.close(); } catch (Exception ignore) { } finally { preStat = null; } } } return obj; }