comparison src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java @ 93:eeb71f7d36bf embedded

Fixed a bug on the JDBC MAPI connection from the old code! Fixed the connection properties for an JDBC Embedded connection. To start a JDBC Embedded connection, the user must start the embedded database beforehand with the method MonetDBEmbeddedDatabase.StartDatabase().
author Pedro Ferreira <pedro.ferreira@monetdbsolutions.com>
date Fri, 06 Jan 2017 12:36:33 +0000 (2017-01-06)
parents 6f74e01c57da
children 4a93f75c72c9
comparison
equal deleted inserted replaced
91:6f74e01c57da 93:eeb71f7d36bf
52 52
53 /** the successful processed input properties */ 53 /** the successful processed input properties */
54 protected final Properties conn_props; 54 protected final Properties conn_props;
55 /** The language to connect with */ 55 /** The language to connect with */
56 protected IMonetDBLanguage language; 56 protected IMonetDBLanguage language;
57 /** The database to connect to */
58 protected String database;
59 /** Authentication hash method */ 57 /** Authentication hash method */
60 protected final String hash; 58 protected final String hash;
61 /** An optional thread that is used for sending large queries */ 59 /** An optional thread that is used for sending large queries */
62 private SenderThread senderThread; 60 private SenderThread senderThread;
63 /** Whether this Connection is closed (and cannot be used anymore) */ 61 /** Whether this Connection is closed (and cannot be used anymore) */
77 // (only when you deal with it of course) 75 // (only when you deal with it of course)
78 /** A Map containing all (active) Statements created from this Connection */ 76 /** A Map containing all (active) Statements created from this Connection */
79 private Map<Statement,?> statements = new WeakHashMap<Statement, Object>(); 77 private Map<Statement,?> statements = new WeakHashMap<Statement, Object>();
80 /** The number of results we receive from the server at once */ 78 /** The number of results we receive from the server at once */
81 private int curReplySize = -1; // the server by default uses -1 (all) 79 private int curReplySize = -1; // the server by default uses -1 (all)
82 /** Whether or not BLOB is mapped to BINARY within the driver */ 80 /** Whether or not BLOB is mapped to LONGVARBINARY within the driver */
83 private final boolean blobIsBinary; 81 private final boolean blobIsBinary;
84 /** Whether or not CLOB is mapped to LONGVARCHAR within the driver */ 82 /** Whether or not CLOB is mapped to LONGVARCHAR within the driver */
85 private final boolean clobIsLongChar; 83 private final boolean clobIsLongChar;
86 /** The underlying proticol provided by the connection (MAPI or embedded) */ 84 /** The underlying proticol provided by the connection (MAPI or embedded) */
87 protected AbstractProtocol protocol; 85 protected AbstractProtocol protocol;
91 * given host, database, username and password for later use by the createStatement() call. This constructor is 89 * given host, database, username and password for later use by the createStatement() call. This constructor is
92 * only accessible to classes from the jdbc package. 90 * only accessible to classes from the jdbc package.
93 * 91 *
94 * @throws IOException if an error occurs 92 * @throws IOException if an error occurs
95 */ 93 */
96 public MonetConnection(Properties props, String database, String hash, IMonetDBLanguage language, 94 public MonetConnection(Properties props, String hash, IMonetDBLanguage language, boolean blobIsBinary,
97 boolean blobIsBinary, boolean clobIsLongChar) throws IOException { 95 boolean clobIsLongChar) throws IOException {
98 this.conn_props = props; 96 this.conn_props = props;
99 this.database = database;
100 this.hash = hash; 97 this.hash = hash;
101 this.language = language; 98 this.language = language;
102 this.blobIsBinary = blobIsBinary; 99 this.blobIsBinary = blobIsBinary;
103 this.clobIsLongChar = clobIsLongChar; 100 this.clobIsLongChar = clobIsLongChar;
104 } 101 }
798 * 795 *
799 * @return a String representing this Object 796 * @return a String representing this Object
800 */ 797 */
801 @Override 798 @Override
802 public String toString() { 799 public String toString() {
803 return "MonetDB Connection (" + this.getJDBCURL() + ") " + (closed ? "connected" : "disconnected"); 800 return "MonetDB Connection (" + this.getJDBCURL() + ") " + (closed ? "disconnected" : "connected");
804 } 801 }
805 802
806 //== Java 1.6 methods (JDBC 4.0) 803 //== Java 1.6 methods (JDBC 4.0)
807 804
808 /** 805 /**
1066 return; 1063 return;
1067 } 1064 }
1068 // only set value for supported property names 1065 // only set value for supported property names
1069 if (name.equals("host") || name.equals("port") || name.equals("user") || name.equals("password") || 1066 if (name.equals("host") || name.equals("port") || name.equals("user") || name.equals("password") ||
1070 name.equals("database") || name.equals("language") || name.equals("so_timeout") || 1067 name.equals("database") || name.equals("language") || name.equals("so_timeout") ||
1071 name.equals("debug") || name.equals("hash") || name.equals("treat_blob_as_binary") || 1068 name.equals("hash") || name.equals("treat_blob_as_binary") || name.equals("follow_redirects") ||
1072 name.equals("treat_clob_as_longvarchar") || name.equals("embedded") || name.equals("directory")) { 1069 name.equals("treat_clob_as_longvarchar") || name.equals("embedded")) {
1073 conn_props.setProperty(name, value); 1070 conn_props.setProperty(name, value);
1074 } else { 1071 } else {
1075 addWarning("setClientInfo: " + name + "is not a recognised property", "01M07"); 1072 addWarning("setClientInfo: " + name + "is not a recognised property", "01M07");
1076 } 1073 }
1077 } 1074 }