List of usage examples for java.sql ResultSet CONCUR_UPDATABLE
int CONCUR_UPDATABLE
To view the source code for java.sql ResultSet CONCUR_UPDATABLE.
Click Source Link
ResultSet
object that may be updated. From source file:InsertRowBug.java
public static void main(String args[]) { String url;/*from ww w. j ava 2s . c o m*/ // url = "jdbc:odbc:SQL Anywhere 5.0 Sample"; // url = "jdbc:oracle:thin:@server:1521:db570"; url = "jdbc:odbc:RainForestDSN"; String driver; //driver = "oracle.jdbc.driver.OracleDriver"; driver = "sun.jdbc.odbc.JdbcOdbcDriver"; String user, pass; user = "student"; pass = "student"; Connection con; Statement stmt; ResultSet uprs; try { Class.forName(driver); } catch (java.lang.ClassNotFoundException e) { System.err.println(e); return; } try { con = DriverManager.getConnection(url, user, pass); stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); uprs = stmt.executeQuery("SELECT * FROM Music_Recordings"); // Check the column count ResultSetMetaData md = uprs.getMetaData(); System.out.println("Resultset has " + md.getColumnCount() + " cols."); int rowNum = uprs.getRow(); System.out.println("row1 " + rowNum); uprs.absolute(1); rowNum = uprs.getRow(); System.out.println("row2 " + rowNum); uprs.next(); uprs.moveToInsertRow(); uprs.updateInt(1, 150); uprs.updateString(2, "Madonna"); uprs.updateString(3, "Dummy"); uprs.updateString(4, "Jazz"); uprs.updateString(5, "Image"); uprs.updateInt(6, 5); uprs.updateDouble(7, 5); uprs.updateInt(8, 15); uprs.insertRow(); uprs.close(); stmt.close(); con.close(); } catch (SQLException ex) { System.err.println("SQLException: " + ex.getMessage()); } }
From source file:Connexion.Charts.java
public Charts() { try {// w ww . j av a2s . 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 {//from w ww . j av a 2 s. c o 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: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;/*from w ww.j ava 2s .c om*/ 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.ChartDocteur.java
public ChartDocteur() { try {/*w w w . j a v a 2 s . com*/ 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:UserPerformance.GetLowerBound.java
public double getLowerB(String GetFixedJobIds) { //get mean from db double Mean_TimePerItem = 0; try {//from ww w.j a v a 2s . co m ResultSet reset; Statement stmt; String query; query = "SELECT AVG(TIME_PER_ONE_ITEM)\n" + " FROM dbo.UsersVsCompleteItems\n" + " WHERE JobFinished_FIXED_JOB_ID = '" + GetFixedJobIds + "'"; stmt = ConnectSql.conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); reset = stmt.executeQuery(query); if (reset.next()) { String wd = reset.getString(1); Mean_TimePerItem = Double.parseDouble(wd); } reset.close(); } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(null, "Please contact for support."); } //get item Count from db double n_Count = 0; try { ResultSet reset; Statement stmt; String query; query = "SELECT COUNT(TIME_PER_ONE_ITEM)\n" + " FROM dbo.UsersVsCompleteItems\n" + " WHERE JobFinished_FIXED_JOB_ID = '" + GetFixedJobIds + "'"; stmt = ConnectSql.conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); reset = stmt.executeQuery(query); if (reset.next()) { String wd = reset.getString(1); n_Count = Double.parseDouble(wd); } reset.close(); } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(null, "Please contact for support."); } //get item Standed deviation from db double st_Dev = 0; try { ResultSet reset; Statement stmt; String query; query = "SELECT STDEV(TIME_PER_ONE_ITEM)\n" + " FROM dbo.UsersVsCompleteItems\n" + " WHERE JobFinished_FIXED_JOB_ID = '" + GetFixedJobIds + "'"; stmt = ConnectSql.conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); reset = stmt.executeQuery(query); if (reset.next()) { st_Dev = reset.getDouble(1); } reset.close(); } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(null, "Please contact for support."); } //get alfa Double alfa = 0.9; System.out.println("Confidence Interval for Fixed Job : " + alfa * 100 + "%"); // Calculate 90% confidence interval double S_Mean_TimePerItem = roundTwoDecimals(Mean_TimePerItem); double ci = calcMeanCI(n_Count, st_Dev, alfa); System.out.println("Mean for Fixed Job : " + S_Mean_TimePerItem); double S_lower = (Mean_TimePerItem - ci); double lower = roundTwoDecimals(S_lower); double S_upper = (Mean_TimePerItem + ci); double upper = roundTwoDecimals(S_upper); System.out.println("lower Limit for Fixed Job : " + lower); return lower; }
From source file:Connexion.ChartMutuelle.java
public ChartMutuelle() { try {/*from w ww . j av a2 s . c om*/ 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.raythos.sql.utils.UpdateExtUserDetailsWorker.java
public void connect(String host, String database, String user, String password) throws Exception { dbUrl = "jdbc:mysql://" + host + "/" + database; Class.forName(jbdcDriver);/*from w ww . ja v a 2 s.c om*/ // Open a connection conn = DriverManager.getConnection(dbUrl, user, password); stmt = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE); updateStmt = conn.prepareStatement(updateSQL); }
From source file:org.biblionum.commentaire.modele.CommentaireOuvragesModele.java
public static boolean updateOuvragetype(DataSource ds, int keyId, String contenu_commentaire, String date_commentaire, int utilisateurid, int ouvrageid) throws SQLException { Connection con = ds.getConnection(); String sql = "SELECT * FROM ouvragetype WHERE id = ?"; PreparedStatement statement = con.prepareStatement(sql, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); statement.setInt(1, keyId);//from w w w .j av a2s . co m ResultSet entry = statement.executeQuery(); entry.last(); int rows = entry.getRow(); entry.beforeFirst(); if (rows == 0) { entry.close(); statement.close(); con.close(); return false; } entry.next(); if (contenu_commentaire != null) { entry.updateString("contenu_commentaire", contenu_commentaire); } if (date_commentaire != null) { entry.updateString("date_commentaire", date_commentaire); } entry.updateInt("utilisateurid", utilisateurid); entry.updateInt("ouvrageid", ouvrageid); entry.updateRow(); entry.close(); statement.close(); con.close(); return true; }
From source file:com.porvak.bracket.social.database.upgrade.v3.UpdateEncryptionMethod.java
License:asdf
@Override protected Statement doCreateStatement(Connection connection) throws SQLException { return connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE); }