Mercurial > hg > monetdb-java
comparison src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java @ 292:b127164342c4
Introduce default general behavior settings DEF_... for MonetResultSets and use them
when creating Statements, PreparedStatements and CallableStatements in MonetConnection.
Corrected documentation for MonetStatement constructor.
Corrected typo "@returns " into "@return ".
author | Martin van Dinther <martin.van.dinther@monetdbsolutions.com> |
---|---|
date | Wed, 31 Jul 2019 19:04:20 +0200 (2019-07-31) |
parents | f412032e3b43 |
children | 003ae6d881db |
comparison
equal
deleted
inserted
replaced
291:611c0954b0e6 | 292:b127164342c4 |
---|---|
431 * executed many times, it may be more efficient to use a | 431 * executed many times, it may be more efficient to use a |
432 * PreparedStatement object. | 432 * PreparedStatement object. |
433 * | 433 * |
434 * Result sets created using the returned Statement object will by | 434 * Result sets created using the returned Statement object will by |
435 * default be type TYPE_FORWARD_ONLY and have a concurrency level of | 435 * default be type TYPE_FORWARD_ONLY and have a concurrency level of |
436 * CONCUR_READ_ONLY. | 436 * CONCUR_READ_ONLY and a holdability of HOLD_CURSORS_OVER_COMMIT. |
437 * | 437 * |
438 * @return a new default Statement object | 438 * @return a new default Statement object |
439 * @throws SQLException if a database access error occurs | 439 * @throws SQLException if a database access error occurs |
440 */ | 440 */ |
441 @Override | 441 @Override |
442 public Statement createStatement() throws SQLException { | 442 public Statement createStatement() throws SQLException { |
443 return createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT); | 443 return createStatement(MonetResultSet.DEF_RESULTSETTYPE, MonetResultSet.DEF_CONCURRENCY, MonetResultSet.DEF_HOLDABILITY); |
444 } | 444 } |
445 | 445 |
446 /** | 446 /** |
447 * Creates a Statement object that will generate ResultSet objects | 447 * Creates a Statement object that will generate ResultSet objects |
448 * with the given type and concurrency. This method is the same as | 448 * with the given type and concurrency. This method is the same as |
458 * the given type and concurrency | 458 * the given type and concurrency |
459 * @throws SQLException if a database access error occurs | 459 * @throws SQLException if a database access error occurs |
460 */ | 460 */ |
461 @Override | 461 @Override |
462 public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException { | 462 public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException { |
463 return createStatement(resultSetType, resultSetConcurrency, ResultSet.HOLD_CURSORS_OVER_COMMIT); | 463 return createStatement(resultSetType, resultSetConcurrency, MonetResultSet.DEF_HOLDABILITY); |
464 } | 464 } |
465 | 465 |
466 /** | 466 /** |
467 * Creates a Statement object that will generate ResultSet objects | 467 * Creates a Statement object that will generate ResultSet objects |
468 * with the given type, concurrency, and holdability. This method | 468 * with the given type, concurrency, and holdability. This method |
674 * @throws SQLException - if a database access error occurs or this method is called on a closed connection | 674 * @throws SQLException - if a database access error occurs or this method is called on a closed connection |
675 * @throws SQLFeatureNotSupportedException - if the JDBC driver does not support this method. | 675 * @throws SQLFeatureNotSupportedException - if the JDBC driver does not support this method. |
676 */ | 676 */ |
677 @Override | 677 @Override |
678 public CallableStatement prepareCall(String sql) throws SQLException { | 678 public CallableStatement prepareCall(String sql) throws SQLException { |
679 return prepareCall(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT); | 679 return prepareCall(sql, MonetResultSet.DEF_RESULTSETTYPE, MonetResultSet.DEF_CONCURRENCY, MonetResultSet.DEF_HOLDABILITY); |
680 } | 680 } |
681 | 681 |
682 /** | 682 /** |
683 * Creates a CallableStatement object that will generate ResultSet objects with the given type and concurrency. | 683 * Creates a CallableStatement object that will generate ResultSet objects with the given type and concurrency. |
684 * This method is the same as the prepareCall method above, but it allows the default result set type and concurrency to be overridden. | 684 * This method is the same as the prepareCall method above, but it allows the default result set type and concurrency to be overridden. |
695 * @throws SQLFeatureNotSupportedException - if the JDBC driver does not support this method or | 695 * @throws SQLFeatureNotSupportedException - if the JDBC driver does not support this method or |
696 * this method is not supported for the specified result set type and result set concurrency. | 696 * this method is not supported for the specified result set type and result set concurrency. |
697 */ | 697 */ |
698 @Override | 698 @Override |
699 public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException { | 699 public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException { |
700 return prepareCall(sql, resultSetType, resultSetConcurrency, ResultSet.HOLD_CURSORS_OVER_COMMIT); | 700 return prepareCall(sql, resultSetType, resultSetConcurrency, MonetResultSet.DEF_HOLDABILITY); |
701 } | 701 } |
702 | 702 |
703 /** | 703 /** |
704 * Creates a CallableStatement object that will generate ResultSet objects with the given type and concurrency. | 704 * Creates a CallableStatement object that will generate ResultSet objects with the given type and concurrency. |
705 * This method is the same as the prepareCall method above, but it allows the default result set type, result set concurrency type and holdability to be overridden. | 705 * This method is the same as the prepareCall method above, but it allows the default result set type, result set concurrency type and holdability to be overridden. |
763 * pre-compiled SQL statement | 763 * pre-compiled SQL statement |
764 * @throws SQLException if a database access error occurs | 764 * @throws SQLException if a database access error occurs |
765 */ | 765 */ |
766 @Override | 766 @Override |
767 public PreparedStatement prepareStatement(String sql) throws SQLException { | 767 public PreparedStatement prepareStatement(String sql) throws SQLException { |
768 return prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT); | 768 return prepareStatement(sql, MonetResultSet.DEF_RESULTSETTYPE, MonetResultSet.DEF_CONCURRENCY, MonetResultSet.DEF_HOLDABILITY); |
769 } | 769 } |
770 | 770 |
771 /** | 771 /** |
772 * Creates a PreparedStatement object that will generate ResultSet | 772 * Creates a PreparedStatement object that will generate ResultSet |
773 * objects with the given type and concurrency. This method is the | 773 * objects with the given type and concurrency. This method is the |
788 * parameters are not ResultSet constants indicating | 788 * parameters are not ResultSet constants indicating |
789 * type and concurrency | 789 * type and concurrency |
790 */ | 790 */ |
791 @Override | 791 @Override |
792 public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException { | 792 public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException { |
793 return prepareStatement(sql, resultSetType, resultSetConcurrency, ResultSet.HOLD_CURSORS_OVER_COMMIT); | 793 return prepareStatement(sql, resultSetType, resultSetConcurrency, MonetResultSet.DEF_HOLDABILITY); |
794 } | 794 } |
795 | 795 |
796 /** | 796 /** |
797 * Creates a PreparedStatement object that will generate ResultSet | 797 * Creates a PreparedStatement object that will generate ResultSet |
798 * objects with the given type, concurrency, and holdability. | 798 * objects with the given type, concurrency, and holdability. |
878 if (autoGeneratedKeys != Statement.RETURN_GENERATED_KEYS && | 878 if (autoGeneratedKeys != Statement.RETURN_GENERATED_KEYS && |
879 autoGeneratedKeys != Statement.NO_GENERATED_KEYS) | 879 autoGeneratedKeys != Statement.NO_GENERATED_KEYS) |
880 throw new SQLException("Invalid argument, expected RETURN_GENERATED_KEYS or NO_GENERATED_KEYS", "M1M05"); | 880 throw new SQLException("Invalid argument, expected RETURN_GENERATED_KEYS or NO_GENERATED_KEYS", "M1M05"); |
881 | 881 |
882 /* MonetDB has no way to disable this, so just do the normal thing ;) */ | 882 /* MonetDB has no way to disable this, so just do the normal thing ;) */ |
883 return prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); | 883 return prepareStatement(sql, MonetResultSet.DEF_RESULTSETTYPE, MonetResultSet.DEF_CONCURRENCY, MonetResultSet.DEF_HOLDABILITY); |
884 } | 884 } |
885 | 885 |
886 /** | 886 /** |
887 * Creates a default PreparedStatement object capable of returning the auto-generated keys designated by the given array. | 887 * Creates a default PreparedStatement object capable of returning the auto-generated keys designated by the given array. |
888 * This array contains the indexes of the columns in the target table that contain the auto-generated keys that should be made available. | 888 * This array contains the indexes of the columns in the target table that contain the auto-generated keys that should be made available. |