comparison src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java @ 77:83aee4f60649

Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods. Throw a SQLFeatureNotSupportedException for not implemented methods: prepareStatement(String sql, int[] columnIndexes) and prepareStatement(String sql, String[] columnNames). Rest of the changes are only layout and removal of trailing tabs.
author Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
date Thu, 15 Dec 2016 15:29:36 +0100 (2016-12-15)
parents 562dbfb2fee8
children a6608e9581c1
comparison
equal deleted inserted replaced
76:3abb3634f467 77:83aee4f60649
394 */ 394 */
395 @Override 395 @Override
396 public void commit() throws SQLException { 396 public void commit() throws SQLException {
397 // note: can't use sendIndependentCommand here because we need 397 // note: can't use sendIndependentCommand here because we need
398 // to process the auto_commit state the server gives 398 // to process the auto_commit state the server gives
399 399 sendTransactionCommand("COMMIT");
400 // create a container for the result
401 ResponseList l = new ResponseList(
402 0,
403 0,
404 ResultSet.FETCH_FORWARD,
405 ResultSet.CONCUR_READ_ONLY
406 );
407 // send commit to the server
408 try {
409 l.processQuery("COMMIT");
410 } finally {
411 l.close();
412 }
413 } 400 }
414 401
415 /** 402 /**
416 * Creates a Statement object for sending SQL statements to the 403 * Creates a Statement object for sending SQL statements to the
417 * database. SQL statements without parameters are normally 404 * database. SQL statements without parameters are normally
426 * @return a new default Statement object 413 * @return a new default Statement object
427 * @throws SQLException if a database access error occurs 414 * @throws SQLException if a database access error occurs
428 */ 415 */
429 @Override 416 @Override
430 public Statement createStatement() throws SQLException { 417 public Statement createStatement() throws SQLException {
431 return createStatement( 418 return createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
432 ResultSet.TYPE_FORWARD_ONLY,
433 ResultSet.CONCUR_READ_ONLY,
434 ResultSet.HOLD_CURSORS_OVER_COMMIT);
435 } 419 }
436 420
437 /** 421 /**
438 * Creates a Statement object that will generate ResultSet objects 422 * Creates a Statement object that will generate ResultSet objects
439 * with the given type and concurrency. This method is the same as 423 * with the given type and concurrency. This method is the same as
448 * @return a new Statement object that will generate ResultSet objects with 432 * @return a new Statement object that will generate ResultSet objects with
449 * the given type and concurrency 433 * the given type and concurrency
450 * @throws SQLException if a database access error occurs 434 * @throws SQLException if a database access error occurs
451 */ 435 */
452 @Override 436 @Override
453 public Statement createStatement( 437 public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException {
454 int resultSetType, 438 return createStatement(resultSetType, resultSetConcurrency, ResultSet.HOLD_CURSORS_OVER_COMMIT);
455 int resultSetConcurrency)
456 throws SQLException
457 {
458 return createStatement(
459 resultSetType,
460 resultSetConcurrency,
461 ResultSet.HOLD_CURSORS_OVER_COMMIT);
462 } 439 }
463 440
464 /** 441 /**
465 * Creates a Statement object that will generate ResultSet objects 442 * Creates a Statement object that will generate ResultSet objects
466 * with the given type, concurrency, and holdability. This method 443 * with the given type, concurrency, and holdability. This method
483 * @throws SQLException if a database access error occurs or the 460 * @throws SQLException if a database access error occurs or the
484 * given parameters are not ResultSet constants indicating type, 461 * given parameters are not ResultSet constants indicating type,
485 * concurrency, and holdability 462 * concurrency, and holdability
486 */ 463 */
487 @Override 464 @Override
488 public Statement createStatement( 465 public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
489 int resultSetType,
490 int resultSetConcurrency,
491 int resultSetHoldability)
492 throws SQLException
493 {
494 try { 466 try {
495 Statement ret = 467 Statement ret = new MonetStatement(this, resultSetType, resultSetConcurrency, resultSetHoldability);
496 new MonetStatement(
497 this,
498 resultSetType,
499 resultSetConcurrency,
500 resultSetHoldability
501 );
502 // store it in the map for when we close... 468 // store it in the map for when we close...
503 statements.put(ret, null); 469 statements.put(ret, null);
504 return ret; 470 return ret;
505 } catch (IllegalArgumentException e) { 471 } catch (IllegalArgumentException e) {
506 throw new SQLException(e.toString(), "M0M03"); 472 throw new SQLException(e.toString(), "M0M03");
508 // we don't have to catch SQLException because that is declared to 474 // we don't have to catch SQLException because that is declared to
509 // be thrown 475 // be thrown
510 } 476 }
511 477
512 /** 478 /**
513 * Retrieves the current auto-commit mode for this Connection 479 * Retrieves the current auto-commit mode for this Connection object.
514 * object. 480 *
515 * 481 * @return the current state of this Connection object's auto-commit mode
516 * @return the current state of this Connection object's auto-commit
517 * mode
518 * @see #setAutoCommit(boolean) 482 * @see #setAutoCommit(boolean)
519 */ 483 */
520 @Override 484 @Override
521 public boolean getAutoCommit() throws SQLException { 485 public boolean getAutoCommit() throws SQLException {
522 return autoCommit; 486 return autoCommit;
532 @Override 496 @Override
533 public String getCatalog() throws SQLException { 497 public String getCatalog() throws SQLException {
534 // MonetDB does NOT support catalogs 498 // MonetDB does NOT support catalogs
535 return null; 499 return null;
536 } 500 }
537 501
538 /** 502 /**
539 * Retrieves the current holdability of ResultSet objects created 503 * Retrieves the current holdability of ResultSet objects created
540 * using this Connection object. 504 * using this Connection object.
541 * 505 *
542 * @return the holdability, one of 506 * @return the holdability, one of
652 public boolean isReadOnly() { 616 public boolean isReadOnly() {
653 return false; 617 return false;
654 } 618 }
655 619
656 @Override 620 @Override
657 public String nativeSQL(String sql) {return sql;} 621 public String nativeSQL(String sql) {
658 622 /* there is currently no way to get the native MonetDB rewritten SQL string back, so just return the original string */
659 @Override 623 /* in future we may replace/remove the escape sequences { <escape-type> ...} before sending it to the server */
660 public CallableStatement prepareCall(String sql) {return null;} 624 return sql;
661 625 }
662 @Override 626
663 public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) {return null;} 627 @Override
664 628 public CallableStatement prepareCall(String sql) {
665 @Override 629 /* not implemented yet */
666 public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) {return null;} 630 return null;
631 }
632
633 @Override
634 public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) {
635 /* not implemented yet */
636 return null;
637 }
638
639 @Override
640 public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) {
641 /* not implemented yet */
642 return null;
643 }
667 644
668 /** 645 /**
669 * Creates a PreparedStatement object for sending parameterized SQL 646 * Creates a PreparedStatement object for sending parameterized SQL
670 * statements to the database. 647 * statements to the database.
671 * 648 *
692 * pre-compiled SQL statement 669 * pre-compiled SQL statement
693 * @throws SQLException if a database access error occurs 670 * @throws SQLException if a database access error occurs
694 */ 671 */
695 @Override 672 @Override
696 public PreparedStatement prepareStatement(String sql) throws SQLException { 673 public PreparedStatement prepareStatement(String sql) throws SQLException {
697 return prepareStatement( 674 return prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
698 sql,
699 ResultSet.TYPE_FORWARD_ONLY,
700 ResultSet.CONCUR_READ_ONLY,
701 ResultSet.HOLD_CURSORS_OVER_COMMIT
702 );
703 } 675 }
704 676
705 /** 677 /**
706 * Creates a PreparedStatement object that will generate ResultSet 678 * Creates a PreparedStatement object that will generate ResultSet
707 * objects with the given type and concurrency. This method is the 679 * objects with the given type and concurrency. This method is the
721 * @throws SQLException if a database access error occurs or the given 693 * @throws SQLException if a database access error occurs or the given
722 * parameters are not ResultSet constants indicating 694 * parameters are not ResultSet constants indicating
723 * type and concurrency 695 * type and concurrency
724 */ 696 */
725 @Override 697 @Override
726 public PreparedStatement prepareStatement( 698 public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
727 String sql, 699 return prepareStatement(sql, resultSetType, resultSetConcurrency, ResultSet.HOLD_CURSORS_OVER_COMMIT);
728 int resultSetType,
729 int resultSetConcurrency)
730 throws SQLException
731 {
732 return prepareStatement(
733 sql,
734 resultSetType,
735 resultSetConcurrency,
736 ResultSet.HOLD_CURSORS_OVER_COMMIT
737 );
738 } 700 }
739 701
740 /** 702 /**
741 * Creates a PreparedStatement object that will generate ResultSet 703 * Creates a PreparedStatement object that will generate ResultSet
742 * objects with the given type, concurrency, and holdability. 704 * objects with the given type, concurrency, and holdability.
762 * @throws SQLException if a database access error occurs or the 724 * @throws SQLException if a database access error occurs or the
763 * given parameters are not ResultSet constants indicating type, 725 * given parameters are not ResultSet constants indicating type,
764 * concurrency, and holdability 726 * concurrency, and holdability
765 */ 727 */
766 @Override 728 @Override
767 public PreparedStatement prepareStatement( 729 public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
768 String sql,
769 int resultSetType,
770 int resultSetConcurrency,
771 int resultSetHoldability)
772 throws SQLException 730 throws SQLException
773 { 731 {
774 try { 732 try {
775 PreparedStatement ret = new MonetPreparedStatement( 733 PreparedStatement ret = new MonetPreparedStatement(
776 this, 734 this,
821 * @throws SQLException - if a database access error occurs or the 779 * @throws SQLException - if a database access error occurs or the
822 * given parameter is not a Statement constant indicating 780 * given parameter is not a Statement constant indicating
823 * whether auto-generated keys should be returned 781 * whether auto-generated keys should be returned
824 */ 782 */
825 @Override 783 @Override
826 public PreparedStatement prepareStatement( 784 public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException {
827 String sql,
828 int autoGeneratedKeys)
829 throws SQLException
830 {
831 if (autoGeneratedKeys != Statement.RETURN_GENERATED_KEYS && 785 if (autoGeneratedKeys != Statement.RETURN_GENERATED_KEYS &&
832 autoGeneratedKeys != Statement.NO_GENERATED_KEYS) 786 autoGeneratedKeys != Statement.NO_GENERATED_KEYS)
833 throw new SQLException("Invalid argument, expected RETURN_GENERATED_KEYS or NO_GENERATED_KEYS", "M1M05"); 787 throw new SQLException("Invalid argument, expected RETURN_GENERATED_KEYS or NO_GENERATED_KEYS", "M1M05");
834 788
835 /* MonetDB has no way to disable this, so just do the normal 789 /* MonetDB has no way to disable this, so just do the normal
836 * thing ;) */ 790 * thing ;) */
837 return prepareStatement( 791 return prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
838 sql, 792 }
839 ResultSet.TYPE_FORWARD_ONLY, 793
840 ResultSet.CONCUR_READ_ONLY 794 /**
841 ); 795 * Creates a default PreparedStatement object capable of returning the auto-generated keys designated by the given array.
842 } 796 * This array contains the indexes of the columns in the target table that contain the auto-generated keys that should be made available.
843 797 * The driver will ignore the array if the SQL statement is not an INSERT statement, or an SQL statement able to
844 @Override 798 * return auto-generated keys (the list of such statements is vendor-specific).
845 public PreparedStatement prepareStatement(String sql, int[] columnIndexes) {return null;} 799 *
846 800 * An SQL statement with or without IN parameters can be pre-compiled and stored in a PreparedStatement object.
847 @Override 801 * This object can then be used to efficiently execute this statement multiple times.
848 public PreparedStatement prepareStatement(String sql, String[] columnNames) {return null;} 802 *
803 * Note: This method is optimized for handling parametric SQL statements that benefit from precompilation.
804 * If the driver supports precompilation, the method prepareStatement will send the statement to the database for precompilation.
805 * Some drivers may not support precompilation. In this case, the statement may not be sent to the database until the PreparedStatement
806 * object is executed. This has no direct effect on users; however, it does affect which methods throw certain SQLExceptions.
807 *
808 * Result sets created using the returned PreparedStatement object will by default be type TYPE_FORWARD_ONLY and have
809 * a concurrency level of CONCUR_READ_ONLY. The holdability of the created result sets can be determined by calling getHoldability().
810 *
811 * Parameters:
812 * sql - an SQL statement that may contain one or more '?' IN parameter placeholders
813 * columnIndexes - an array of column indexes indicating the columns that should be returned from the inserted row or rows
814 * Returns:
815 * a new PreparedStatement object, containing the pre-compiled statement, that is capable of
816 * returning the auto-generated keys designated by the given array of column indexes
817 * Throws:
818 * SQLException - if a database access error occurs or this method is called on a closed connection
819 * SQLFeatureNotSupportedException - if the JDBC driver does not support this method
820 */
821 @Override
822 public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException {
823 throw new SQLFeatureNotSupportedException("prepareStatement(String sql, int[] columnIndexes) not supported", "0A000");
824 }
825
826 /**
827 * Creates a default PreparedStatement object capable of returning the auto-generated keys designated by the given array.
828 * This array contains the names of the columns in the target table that contain the auto-generated keys that should be returned.
829 * The driver will ignore the array if the SQL statement is not an INSERT statement, or an SQL statement able to
830 * return auto-generated keys (the list of such statements is vendor-specific).
831 *
832 * An SQL statement with or without IN parameters can be pre-compiled and stored in a PreparedStatement object.
833 * This object can then be used to efficiently execute this statement multiple times.
834 *
835 * Note: This method is optimized for handling parametric SQL statements that benefit from precompilation.
836 * If the driver supports precompilation, the method prepareStatement will send the statement to the database for precompilation.
837 * Some drivers may not support precompilation. In this case, the statement may not be sent to the database until the PreparedStatement
838 * object is executed. This has no direct effect on users; however, it does affect which methods throw certain SQLExceptions.
839 *
840 * Result sets created using the returned PreparedStatement object will by default be type TYPE_FORWARD_ONLY and have
841 * a concurrency level of CONCUR_READ_ONLY. The holdability of the created result sets can be determined by calling getHoldability().
842 *
843 * Parameters:
844 * sql - an SQL statement that may contain one or more '?' IN parameter placeholders
845 * columnNames - an array of column names indicating the columns that should be returned from the inserted row or rows
846 * Returns:
847 * a new PreparedStatement object, containing the pre-compiled statement, that is capable of
848 * returning the auto-generated keys designated by the given array of column names
849 * Throws:
850 * SQLException - if a database access error occurs or this method is called on a closed connection
851 * SQLFeatureNotSupportedException - if the JDBC driver does not support this method
852 */
853 @Override
854 public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException {
855 throw new SQLFeatureNotSupportedException("prepareStatement(String sql, String[] columnNames) not supported", "0A000");
856 }
849 857
850 /** 858 /**
851 * Removes the given Savepoint object from the current transaction. 859 * Removes the given Savepoint object from the current transaction.
852 * Any reference to the savepoint after it have been removed will 860 * Any reference to the savepoint after it have been removed will
853 * cause an SQLException to be thrown. 861 * cause an SQLException to be thrown.
864 872
865 MonetSavepoint sp = (MonetSavepoint)savepoint; 873 MonetSavepoint sp = (MonetSavepoint)savepoint;
866 874
867 // note: can't use sendIndependentCommand here because we need 875 // note: can't use sendIndependentCommand here because we need
868 // to process the auto_commit state the server gives 876 // to process the auto_commit state the server gives
869 877 sendTransactionCommand("RELEASE SAVEPOINT " + sp.getName());
870 // create a container for the result
871 ResponseList l = new ResponseList(
872 0,
873 0,
874 ResultSet.FETCH_FORWARD,
875 ResultSet.CONCUR_READ_ONLY
876 );
877 // send the appropriate query string to the database
878 try {
879 l.processQuery("RELEASE SAVEPOINT " + sp.getName());
880 } finally {
881 l.close();
882 }
883 } 878 }
884 879
885 /** 880 /**
886 * Undoes all changes made in the current transaction and releases 881 * Undoes all changes made in the current transaction and releases
887 * any database locks currently held by this Connection object. 882 * any database locks currently held by this Connection object.
893 */ 888 */
894 @Override 889 @Override
895 public void rollback() throws SQLException { 890 public void rollback() throws SQLException {
896 // note: can't use sendIndependentCommand here because we need 891 // note: can't use sendIndependentCommand here because we need
897 // to process the auto_commit state the server gives 892 // to process the auto_commit state the server gives
898 893 sendTransactionCommand("ROLLBACK");
899 // create a container for the result
900 ResponseList l = new ResponseList(
901 0,
902 0,
903 ResultSet.FETCH_FORWARD,
904 ResultSet.CONCUR_READ_ONLY
905 );
906 // send rollback to the server
907 try {
908 l.processQuery("ROLLBACK");
909 } finally {
910 l.close();
911 }
912 } 894 }
913 895
914 /** 896 /**
915 * Undoes all changes made after the given Savepoint object was set. 897 * Undoes all changes made after the given Savepoint object was set.
916 * 898 *
928 910
929 MonetSavepoint sp = (MonetSavepoint)savepoint; 911 MonetSavepoint sp = (MonetSavepoint)savepoint;
930 912
931 // note: can't use sendIndependentCommand here because we need 913 // note: can't use sendIndependentCommand here because we need
932 // to process the auto_commit state the server gives 914 // to process the auto_commit state the server gives
933 915 sendTransactionCommand("ROLLBACK TO SAVEPOINT " + sp.getName());
934 // create a container for the result
935 ResponseList l = new ResponseList(
936 0,
937 0,
938 ResultSet.FETCH_FORWARD,
939 ResultSet.CONCUR_READ_ONLY
940 );
941 // send the appropriate query string to the database
942 try {
943 l.processQuery("ROLLBACK TO SAVEPOINT " + sp.getName());
944 } finally {
945 l.close();
946 }
947 } 916 }
948 917
949 /** 918 /**
950 * Sets this connection's auto-commit mode to the given state. If a 919 * Sets this connection's auto-commit mode to the given state. If a
951 * connection is in auto-commit mode, then all its SQL statements 920 * connection is in auto-commit mode, then all its SQL statements
1034 // create a new Savepoint object 1003 // create a new Savepoint object
1035 MonetSavepoint sp = new MonetSavepoint(); 1004 MonetSavepoint sp = new MonetSavepoint();
1036 1005
1037 // note: can't use sendIndependentCommand here because we need 1006 // note: can't use sendIndependentCommand here because we need
1038 // to process the auto_commit state the server gives 1007 // to process the auto_commit state the server gives
1039 1008 sendTransactionCommand("SAVEPOINT " + sp.getName());
1040 // create a container for the result
1041 ResponseList l = new ResponseList(
1042 0,
1043 0,
1044 ResultSet.FETCH_FORWARD,
1045 ResultSet.CONCUR_READ_ONLY
1046 );
1047 // send the appropriate query string to the database
1048 try {
1049 l.processQuery("SAVEPOINT " + sp.getName());
1050 } finally {
1051 l.close();
1052 }
1053
1054 return sp; 1009 return sp;
1055 } 1010 }
1056 1011
1057 /** 1012 /**
1058 * Creates a savepoint with the given name in the current transaction 1013 * Creates a savepoint with the given name in the current transaction
1073 throw new SQLException(e.getMessage(), "M0M03"); 1028 throw new SQLException(e.getMessage(), "M0M03");
1074 } 1029 }
1075 1030
1076 // note: can't use sendIndependentCommand here because we need 1031 // note: can't use sendIndependentCommand here because we need
1077 // to process the auto_commit state the server gives 1032 // to process the auto_commit state the server gives
1078 1033 sendTransactionCommand("SAVEPOINT " + sp.getName());
1079 // create a container for the result
1080 ResponseList l = new ResponseList(
1081 0,
1082 0,
1083 ResultSet.FETCH_FORWARD,
1084 ResultSet.CONCUR_READ_ONLY
1085 );
1086 // send the appropriate query string to the database
1087 try {
1088 l.processQuery("SAVEPOINT " + sp.getName());
1089 } finally {
1090 l.close();
1091 }
1092
1093 return sp; 1034 return sp;
1094 } 1035 }
1095 1036
1096 /** 1037 /**
1097 * Attempts to change the transaction isolation level for this 1038 * Attempts to change the transaction isolation level for this
1168 * @throws SQLFeatureNotSupportedException the JDBC driver does 1109 * @throws SQLFeatureNotSupportedException the JDBC driver does
1169 * not support this data type 1110 * not support this data type
1170 * @since 1.6 1111 * @since 1.6
1171 */ 1112 */
1172 @Override 1113 @Override
1173 public java.sql.Array createArrayOf(String typeName, Object[] elements) 1114 public java.sql.Array createArrayOf(String typeName, Object[] elements) throws SQLException {
1174 throws SQLException
1175 {
1176 throw new SQLFeatureNotSupportedException("createArrayOf() not supported", "0A000"); 1115 throw new SQLFeatureNotSupportedException("createArrayOf() not supported", "0A000");
1177 } 1116 }
1178 1117
1179 1118
1180 /** 1119 /**
1241 * @throws SQLFeatureNotSupportedException the JDBC driver does 1180 * @throws SQLFeatureNotSupportedException the JDBC driver does
1242 * not support this data type 1181 * not support this data type
1243 * @since 1.6 1182 * @since 1.6
1244 */ 1183 */
1245 @Override 1184 @Override
1246 public java.sql.Struct createStruct(String typeName, Object[] attributes) 1185 public java.sql.Struct createStruct(String typeName, Object[] attributes) throws SQLException {
1247 throws SQLException
1248 {
1249 throw new SQLFeatureNotSupportedException("createStruct() not supported", "0A000"); 1186 throw new SQLFeatureNotSupportedException("createStruct() not supported", "0A000");
1250 } 1187 }
1251 1188
1252 /** 1189 /**
1253 * Constructs an object that implements the SQLXML interface. The 1190 * Constructs an object that implements the SQLXML interface. The
1559 * method is called on a closed connection, the executor is 1496 * method is called on a closed connection, the executor is
1560 * null, or the value specified for seconds is less than 0. 1497 * null, or the value specified for seconds is less than 0.
1561 * @since 1.7 1498 * @since 1.7
1562 */ 1499 */
1563 @Override 1500 @Override
1564 public void setNetworkTimeout(Executor executor, int millis) 1501 public void setNetworkTimeout(Executor executor, int millis) throws SQLException {
1565 throws SQLException
1566 {
1567 if (closed) 1502 if (closed)
1568 throw new SQLException("Cannot call on closed Connection", "M1M20"); 1503 throw new SQLException("Cannot call on closed Connection", "M1M20");
1569 if (executor == null) 1504 if (executor == null)
1570 throw new SQLException("executor is null", "M1M05"); 1505 throw new SQLException("executor is null", "M1M05");
1571 if (millis < 0) 1506 if (millis < 0)
1620 /** 1555 /**
1621 * Returns whether the BLOB type should be mapped to BINARY type. 1556 * Returns whether the BLOB type should be mapped to BINARY type.
1622 */ 1557 */
1623 boolean getBlobAsBinary() { 1558 boolean getBlobAsBinary() {
1624 return blobIsBinary; 1559 return blobIsBinary;
1560 }
1561
1562
1563 /**
1564 * Sends the given string to MonetDB as special transaction command.
1565 * All possible returned information is discarded.
1566 * Encountered errors are reported.
1567 *
1568 * @param command the exact string to send to MonetDB
1569 * @throws SQLException if an IO exception or a database error occurs
1570 */
1571 private void sendTransactionCommand(String command) throws SQLException {
1572 // create a container for the result
1573 ResponseList l = new ResponseList(0, 0, ResultSet.FETCH_FORWARD, ResultSet.CONCUR_READ_ONLY);
1574 // send the appropriate query string to the database
1575 try {
1576 l.processQuery(command);
1577 } finally {
1578 l.close();
1579 }
1625 } 1580 }
1626 1581
1627 /** 1582 /**
1628 * Sends the given string to MonetDB as regular statement, making 1583 * Sends the given string to MonetDB as regular statement, making
1629 * sure there is a prompt after the command is sent. All possible 1584 * sure there is a prompt after the command is sent. All possible
1943 * @return an array of Strings 1898 * @return an array of Strings
1944 */ 1899 */
1945 final private String[] getValues(char[] chrLine, int start, int stop) { 1900 final private String[] getValues(char[] chrLine, int start, int stop) {
1946 int elem = 0; 1901 int elem = 0;
1947 String[] values = new String[columncount]; 1902 String[] values = new String[columncount];
1948 1903
1949 for (int i = start; i < stop; i++) { 1904 for (int i = start; i < stop; i++) {
1950 if (chrLine[i] == '\t' && chrLine[i - 1] == ',') { 1905 if (chrLine[i] == '\t' && chrLine[i - 1] == ',') {
1951 values[elem++] = 1906 values[elem++] =
1952 new String(chrLine, start, i - 1 - start); 1907 new String(chrLine, start, i - 1 - start);
1953 start = i + 1; 1908 start = i + 1;
2174 boolean isClosed() { 2129 boolean isClosed() {
2175 return closed; 2130 return closed;
2176 } 2131 }
2177 } 2132 }
2178 // }}} 2133 // }}}
2179 2134
2180 /** 2135 /**
2181 * The DataBlockResponse is tabular data belonging to a 2136 * The DataBlockResponse is tabular data belonging to a
2182 * ResultSetResponse. Tabular data from the server typically looks 2137 * ResultSetResponse. Tabular data from the server typically looks
2183 * like: 2138 * like:
2184 * <pre> 2139 * <pre>
2306 */ 2261 */
2307 // {{{ UpdateResponse class implementation 2262 // {{{ UpdateResponse class implementation
2308 static class UpdateResponse implements Response { 2263 static class UpdateResponse implements Response {
2309 public final int count; 2264 public final int count;
2310 public final String lastid; 2265 public final String lastid;
2311 2266
2312 public UpdateResponse(int cnt, String id) { 2267 public UpdateResponse(int cnt, String id) {
2313 // fill the blank finals 2268 // fill the blank finals
2314 this.count = cnt; 2269 this.count = cnt;
2315 this.lastid = id; 2270 this.lastid = id;
2316 } 2271 }
2347 * <tt>&amp;3</tt> 2302 * <tt>&amp;3</tt>
2348 */ 2303 */
2349 // {{{ SchemaResponse class implementation 2304 // {{{ SchemaResponse class implementation
2350 class SchemaResponse implements Response { 2305 class SchemaResponse implements Response {
2351 public final int state = Statement.SUCCESS_NO_INFO; 2306 public final int state = Statement.SUCCESS_NO_INFO;
2352 2307
2353 @Override 2308 @Override
2354 public String addLine(String line, int linetype) { 2309 public String addLine(String line, int linetype) {
2355 return "Header lines are not supported for a SchemaResponse"; 2310 return "Header lines are not supported for a SchemaResponse";
2356 } 2311 }
2357 2312
2378 * <tt>&amp;4 (t|f)</tt> 2333 * <tt>&amp;4 (t|f)</tt>
2379 */ 2334 */
2380 // {{{ AutoCommitResponse class implementation 2335 // {{{ AutoCommitResponse class implementation
2381 class AutoCommitResponse extends SchemaResponse { 2336 class AutoCommitResponse extends SchemaResponse {
2382 public final boolean autocommit; 2337 public final boolean autocommit;
2383 2338
2384 public AutoCommitResponse(boolean ac) { 2339 public AutoCommitResponse(boolean ac) {
2385 // fill the blank final 2340 // fill the blank final
2386 this.autocommit = ac; 2341 this.autocommit = ac;
2387 } 2342 }
2388 } 2343 }
2821 private String[] templ; 2776 private String[] templ;
2822 private String query; 2777 private String query;
2823 private BufferedMCLWriter out; 2778 private BufferedMCLWriter out;
2824 private String error; 2779 private String error;
2825 private int state = WAIT; 2780 private int state = WAIT;
2826 2781
2827 final Lock sendLock = new ReentrantLock(); 2782 final Lock sendLock = new ReentrantLock();
2828 final Condition queryAvailable = sendLock.newCondition(); 2783 final Condition queryAvailable = sendLock.newCondition();
2829 final Condition waiting = sendLock.newCondition(); 2784 final Condition waiting = sendLock.newCondition();
2830 2785
2831 /** 2786 /**