Mercurial > hg > monetdb-java
comparison src/main/java/nl/cwi/monetdb/jdbc/MonetDataSource.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 | 08bc9009d190 |
comparison
equal
deleted
inserted
replaced
91:6f74e01c57da | 93:eeb71f7d36bf |
---|---|
33 private String user; | 33 private String user; |
34 private String password; // insecure, but how to do it better? | 34 private String password; // insecure, but how to do it better? |
35 private String description = "MonetDB database"; | 35 private String description = "MonetDB database"; |
36 private String url = "jdbc:monetdb://localhost/"; | 36 private String url = "jdbc:monetdb://localhost/"; |
37 private int loginTimeout; | 37 private int loginTimeout; |
38 private String embeddedDirectory; | 38 private boolean isEmbedded; |
39 private final MonetDriver driver = new MonetDriver(); | 39 private final MonetDriver driver = new MonetDriver(); |
40 | 40 |
41 // the following properties are also standard: | 41 // the following properties are also standard: |
42 // private String dataSourceName; | 42 // private String dataSourceName; |
43 // private String networkProtocol; | 43 // private String networkProtocol; |
71 props.put("user", username); | 71 props.put("user", username); |
72 props.put("password", password); | 72 props.put("password", password); |
73 if (loginTimeout > 0) { | 73 if (loginTimeout > 0) { |
74 props.put("so_timeout", Integer.toString(loginTimeout)); | 74 props.put("so_timeout", Integer.toString(loginTimeout)); |
75 } | 75 } |
76 if(embeddedDirectory != null) { | 76 if(isEmbedded) { |
77 props.put("embedded", "true"); | 77 props.put("embedded", "true"); |
78 props.put("directory", embeddedDirectory); | |
79 } | 78 } |
80 return driver.connect(url, props); | 79 return driver.connect(url, props); |
81 } | 80 } |
82 | 81 |
83 /** | 82 /** |
158 /** | 157 /** |
159 * Sets the connection URL | 158 * Sets the connection URL |
160 * | 159 * |
161 * @param url the connection URL | 160 * @param url the connection URL |
162 */ | 161 */ |
163 public void setDatabaseName(String url) { | 162 public void setURL(String url) { |
164 this.url = url; | 163 this.url = url; |
165 } | 164 } |
166 | 165 |
167 /** | 166 /** |
168 * Gets the description | 167 * Gets the description |
181 public void setDescription(String description) { | 180 public void setDescription(String description) { |
182 this.description = description; | 181 this.description = description; |
183 } | 182 } |
184 | 183 |
185 /** | 184 /** |
186 * Gets the embedded connection directory. If null, then a MAPI connection will be created instead. | 185 * Gets the embedded connection directory. If not, then a MAPI connection will be created instead. |
187 * | 186 * |
188 * @return The embedded connection directory String. If null, then a MAPI connection will be created instead. | 187 * @return If the connection will be embedded. If not, then a MAPI connection will be created instead. |
189 */ | 188 */ |
190 public String getEmbeddedDirectory() { | 189 public boolean isEmbedded() { |
191 return embeddedDirectory; | 190 return isEmbedded; |
192 } | 191 } |
193 | 192 |
194 /** | 193 /** |
195 * Sets the embedded connection directory, thus making the connection embedded. | 194 * Sets the connection to be embedded |
196 * | 195 * |
197 * @param embeddedDirectory The embedded connection directory to set | 196 * @param isEmbedded A boolean to indicate if the connection will be embedded |
198 */ | 197 */ |
199 public void setEmbeddedDirectory(String embeddedDirectory) { | 198 public void setIsEmbedded(boolean isEmbedded) { |
200 this.embeddedDirectory = embeddedDirectory; | 199 this.isEmbedded = isEmbedded; |
201 } | 200 } |
202 | 201 |
203 /** | 202 /** |
204 * Return the parent Logger of all the Loggers used by this data | 203 * Return the parent Logger of all the Loggers used by this data |
205 * source. This should be the Logger farthest from the root Logger | 204 * source. This should be the Logger farthest from the root Logger |