Mercurial > hg > monetdb-java
comparison src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java @ 184:e0f76fedafc8
Corrected implementation of Connection.prepareCall() methods. They used to return null.
Now it throws an SQLFeatureNotSupportedException to comply with the JDBC specification.
Also added missing javadoc comments.
author | Martin van Dinther <martin.van.dinther@monetdbsolutions.com> |
---|---|
date | Thu, 05 Oct 2017 19:17:41 +0200 (2017-10-05) |
parents | dd12348c41cf |
children | 4767b005a531 |
comparison
equal
deleted
inserted
replaced
183:57f09396b22c | 184:e0f76fedafc8 |
---|---|
158 * @throws IllegalArgumentException is one of the arguments is null or empty | 158 * @throws IllegalArgumentException is one of the arguments is null or empty |
159 */ | 159 */ |
160 MonetConnection(Properties props) | 160 MonetConnection(Properties props) |
161 throws SQLException, IllegalArgumentException | 161 throws SQLException, IllegalArgumentException |
162 { | 162 { |
163 // for debug: System.out.println("New connection object. Received properties are: " + props.toString()); | |
163 // get supported property values from the props argument. | 164 // get supported property values from the props argument. |
164 // When a value is found add it to the internal conn_props list for use by getClientInfo(). | 165 // When a value is found add it to the internal conn_props list for use by getClientInfo(). |
165 this.hostname = props.getProperty("host"); | 166 this.hostname = props.getProperty("host"); |
166 if (this.hostname != null) | 167 if (this.hostname != null) |
167 conn_props.setProperty("host", this.hostname); | 168 conn_props.setProperty("host", this.hostname); |
629 @Override | 630 @Override |
630 public boolean isReadOnly() { | 631 public boolean isReadOnly() { |
631 return false; | 632 return false; |
632 } | 633 } |
633 | 634 |
635 /** | |
636 * Converts the given SQL statement into the system's native SQL grammar. | |
637 * A driver may convert the JDBC SQL grammar into its system's native SQL grammar prior to sending it. | |
638 * This method returns the native form of the statement that the driver would have sent. | |
639 * | |
640 * Parameters: | |
641 * sql - an SQL statement that may contain one or more '?' parameter placeholders. | |
642 * Returns: the native form of this statement | |
643 * Throws: SQLException - if a database access error occurs or this method is called on a closed connection | |
644 */ | |
634 @Override | 645 @Override |
635 public String nativeSQL(String sql) { | 646 public String nativeSQL(String sql) { |
636 /* there is currently no way to get the native MonetDB rewritten SQL string back, so just return the original string */ | 647 /* there is currently no way to get the native MonetDB rewritten SQL string back, so just return the original string */ |
637 /* in future we may replace/remove the escape sequences { <escape-type> ...} before sending it to the server */ | 648 /* in future we may replace/remove the escape sequences { <escape-type> ...} before sending it to the server */ |
638 return sql; | 649 return sql; |
639 } | 650 } |
640 | 651 |
641 @Override | 652 /** |
642 public CallableStatement prepareCall(String sql) { | 653 * Creates a CallableStatement object for calling database stored procedures. |
643 /* not implemented yet */ | 654 * The CallableStatement object provides methods for setting up its IN and OUT parameters, |
644 return null; | 655 * and methods for executing the call to a stored procedure. |
645 } | 656 * |
646 | 657 * Note: This method is optimized for handling stored procedure call statements. |
647 @Override | 658 * Some drivers may send the call statement to the database when the method prepareCall is done; |
648 public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) { | 659 * others may wait until the CallableStatement object is executed. This has no direct effect |
649 /* not implemented yet */ | 660 * on users; however, it does affect which method throws certain SQLExceptions. |
650 return null; | 661 * |
651 } | 662 * Result sets created using the returned CallableStatement object will by default be type TYPE_FORWARD_ONLY |
652 | 663 * and have a concurrency level of CONCUR_READ_ONLY. |
653 @Override | 664 * The holdability of the created result sets can be determined by calling getHoldability(). |
654 public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) { | 665 * |
655 /* not implemented yet */ | 666 * Parameters: |
656 return null; | 667 * sql - an SQL statement that may contain one or more '?' parameter placeholders. |
668 * Typically this statement is specified using JDBC call escape syntax. | |
669 * Returns: a new default CallableStatement object containing the pre-compiled SQL statement | |
670 * Throws: SQLException - if a database access error occurs or this method is called on a closed connection | |
671 */ | |
672 @Override | |
673 public CallableStatement prepareCall(String sql) throws SQLException { | |
674 return prepareCall(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT); | |
675 } | |
676 | |
677 /** | |
678 * Creates a CallableStatement object that will generate ResultSet objects with the given type and concurrency. | |
679 * This method is the same as the prepareCall method above, but it allows the default result set type and concurrency to be overridden. | |
680 * The holdability of the created result sets can be determined by calling getHoldability(). | |
681 * | |
682 * Parameters: | |
683 * sql - a String object that is the SQL statement to be sent to the database; may contain on or more '?' parameters | |
684 * Typically this statement is specified using JDBC call escape syntax. | |
685 * resultSetType - a result set type; one of ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE | |
686 * resultSetConcurrency - a concurrency type; one of ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE | |
687 * Returns: a new CallableStatement object containing the pre-compiled SQL statement that | |
688 * will produce ResultSet objects with the given type and concurrency | |
689 * Throws: | |
690 * SQLException - if a database access error occurs, this method is called on a closed connection or | |
691 * the given parameters are not ResultSet constants indicating type and concurrency | |
692 * SQLFeatureNotSupportedException - if the JDBC driver does not support this method or | |
693 * this method is not supported for the specified result set type and result set concurrency. | |
694 */ | |
695 @Override | |
696 public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException { | |
697 return prepareCall(sql, resultSetType, resultSetConcurrency, ResultSet.HOLD_CURSORS_OVER_COMMIT); | |
698 } | |
699 | |
700 /** | |
701 * Creates a CallableStatement object that will generate ResultSet objects with the given type and concurrency. | |
702 * 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. | |
703 * | |
704 * Parameters: | |
705 * sql - a String object that is the SQL statement to be sent to the database; may contain on or more '?' parameters | |
706 * Typically this statement is specified using JDBC call escape syntax. | |
707 * resultSetType - a result set type; one of ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE | |
708 * resultSetConcurrency - a concurrency type; one of ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE | |
709 * resultSetHoldability - one of the following ResultSet constants: ResultSet.HOLD_CURSORS_OVER_COMMIT or ResultSet.CLOSE_CURSORS_AT_COMMIT | |
710 * Returns: a new CallableStatement object, containing the pre-compiled SQL statement, that will generate ResultSet objects with the given type, concurrency, and holdability | |
711 * Throws: | |
712 * SQLException - if a database access error occurs, this method is called on a closed connection or | |
713 * the given parameters are not ResultSet constants indicating type, concurrency, and holdability | |
714 * SQLFeatureNotSupportedException - if the JDBC driver does not support this method or | |
715 * this method is not supported for the specified result set type, result set holdability and result set concurrency. | |
716 */ | |
717 @Override | |
718 public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) | |
719 throws SQLException | |
720 { | |
721 throw new SQLFeatureNotSupportedException("prepareCall() not yet supported", "0A000"); | |
722 /* a request to implement prepareCall() has already been logged, see https://www.monetdb.org/bugzilla/show_bug.cgi?id=6402 */ | |
657 } | 723 } |
658 | 724 |
659 /** | 725 /** |
660 * Creates a PreparedStatement object for sending parameterized SQL | 726 * Creates a PreparedStatement object for sending parameterized SQL |
661 * statements to the database. | 727 * statements to the database. |