List of usage examples for java.sql ResultSet TYPE_FORWARD_ONLY
int TYPE_FORWARD_ONLY
To view the source code for java.sql ResultSet TYPE_FORWARD_ONLY.
Click Source Link
ResultSet
object whose cursor may move only forward. From source file:Main.java
public static void main(String[] args) throws Exception { Connection conn = getConnection(); DatabaseMetaData dbmd = conn.getMetaData(); if (dbmd.supportsResultSetConcurrency(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE)) { System.out.println("Updatable ResultSets are supported"); } else {/*from ww w . ja v a 2s. c om*/ System.out.println("Updatable ResultSets are not supported"); } conn.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { Connection conn = getHSQLConnection(); DatabaseMetaData md = conn.getMetaData(); System.out.println("supportsResultSetType - " + md.supportsResultSetConcurrency(ResultSet.TYPE_FORWARD_ONLY, ResultSet.FETCH_UNKNOWN)); conn.close();//from ww w . j av a 2 s . c om }
From source file:Main.java
public static void main(String[] args) throws Exception { Class.forName(DRIVER);//w ww . ja va 2s . c o m Connection connection = DriverManager.getConnection(URL, USERNAME, PASSWORD); DatabaseMetaData metadata = connection.getMetaData(); boolean updatable = metadata.supportsResultSetConcurrency(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE); System.out.println("Updatable ResultSet supported = " + updatable); connection.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { Class.forName(DRIVER);//from w w w. j a va 2 s . c o m Connection connection = DriverManager.getConnection(URL, USERNAME, PASSWORD); DatabaseMetaData metadata = connection.getMetaData(); boolean supportForwardOnly = metadata.supportsResultSetType(ResultSet.TYPE_FORWARD_ONLY); System.out.println("supportForwardOnly = " + supportForwardOnly); boolean supportScrollInsensitive = metadata.supportsResultSetType(ResultSet.TYPE_SCROLL_INSENSITIVE); System.out.println("supportScrollInsensitive = " + supportScrollInsensitive); boolean supportScrollSensitive = metadata.supportsResultSetType(ResultSet.TYPE_SCROLL_SENSITIVE); System.out.println("supportScrollSensitive = " + supportScrollSensitive); connection.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { Connection conn = getMySqlConnection(); System.out.println("Got Connection."); Statement st = conn.createStatement(); st.executeUpdate("drop table survey;"); st.executeUpdate("create table survey (id int,name varchar(30));"); st.executeUpdate("insert into survey (id,name ) values (1,'nameValue')"); DatabaseMetaData meta = conn.getMetaData(); if (meta.supportsResultSetType(ResultSet.TYPE_FORWARD_ONLY)) { System.out.println("type name=TYPE_FORWARD_ONLY"); }/*from w w w. j a v a2 s . c o m*/ if (meta.supportsResultSetType(ResultSet.TYPE_SCROLL_INSENSITIVE)) { System.out.println("type name=TYPE_SCROLL_INSENSITIVE"); } if (meta.supportsResultSetType(ResultSet.TYPE_SCROLL_SENSITIVE)) { System.out.println("type name=TYPE_SCROLL_SENSITIVE"); } st.close(); conn.close(); }
From source file:Main.java
public static void main(String[] argv) throws Exception { String driverName = "com.jnetdirect.jsql.JSQLDriver"; Class.forName(driverName);/*ww w. ja v a2 s . c o m*/ String serverName = "127.0.0.1"; String portNumber = "1433"; String mydatabase = serverName + ":" + portNumber; String url = "jdbc:JSQLConnect://" + mydatabase; String username = "username"; String password = "password"; Connection connection = DriverManager.getConnection(url, username, password); DatabaseMetaData dmd = connection.getMetaData(); if (dmd.supportsResultSetConcurrency(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE)) { System.out.println("Updatable result sets are supported"); } else { System.out.println("Updatable result sets are not supported"); } }
From source file:Main.java
public static void main(String[] args) throws Exception { Connection conn = getConnection(); Statement st = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); st.executeUpdate("create table survey (id int,name varchar(30));"); st.executeUpdate("insert into survey (id,name ) values (1,'nameValue')"); st.executeUpdate("insert into survey (id,name ) values (2,null)"); st = conn.createStatement();//from ww w .j a v a2 s .c o m ResultSet rs = st.executeQuery("SELECT * FROM survey"); int rsType = rs.getType(); if (rsType == java.sql.ResultSet.TYPE_FORWARD_ONLY) { System.out.println("java.sql.ResultSet.TYPE_FORWARD_ONLY"); } else if (rsType == java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE) { System.out.println("java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE"); } else if (rsType == java.sql.ResultSet.TYPE_SCROLL_SENSITIVE) { System.out.println("java.sql.ResultSet.TYPE_SCROLL_SENSITIVE"); } else { // it is an error } rs.close(); st.close(); conn.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { Connection con = DriverManager.getConnection("jdbc:mysql://192.168.1.3/zzzTest?" + // "useUnicode=yes&characterEncoding=UTF-8" + // "&user=root&password=whatever"); String newName = "G"; String newEmail = "g@example.com"; String newMobile = "444-555-2222"; String sql = "SELECT " + // "id, " + // "name, " + // "email, " + // "mobile " + // "FROM registerSmsUsers " + // "WHERE mobile = ? " + // "FOR UPDATE"; PreparedStatement pst = con.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE); pst.setString(1, newMobile);//from ww w . j a va2 s . c o m ResultSet rs = pst.executeQuery(); if (rs.next()) { rs.moveToCurrentRow(); rs.updateString("name", newName); rs.updateString("email", newEmail); rs.updateRow(); System.out.println("Existing row updated."); } else { rs.moveToInsertRow(); rs.updateString("name", newName); rs.updateString("email", newEmail); rs.updateString("mobile", newMobile); rs.insertRow(); System.out.println("New row inserted."); } }
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 ava 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:com.javacreed.examples.spring.StreamingStatementCreator.java
@Override public PreparedStatement createPreparedStatement(final Connection connection) throws SQLException { final PreparedStatement statement = connection.prepareStatement(query, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); statement.setFetchSize(Integer.MIN_VALUE); return statement; }