comparison src/main/java/org/monetdb/jdbc/MonetDriver.java @ 931:df18aa5c8a61

Add test for MonetDriver.getPropertyInfo(url, props). The implementation is moved to Parameter.java which contains the list of connection parameters. It currently only returns the mandatory connection parameters.
author Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
date Thu, 24 Oct 2024 19:10:06 +0200 (5 months ago)
parents ff7dbded88c8
children d416e9b6b3d0
comparison
equal deleted inserted replaced
930:8611e23d2771 931:df18aa5c8a61
10 * Copyright 1997 - July 2008 CWI. 10 * Copyright 1997 - July 2008 CWI.
11 */ 11 */
12 12
13 package org.monetdb.jdbc; 13 package org.monetdb.jdbc;
14 14
15 import org.monetdb.mcl.net.Parameter;
15 import org.monetdb.mcl.net.Target; 16 import org.monetdb.mcl.net.Target;
16 import org.monetdb.mcl.net.ValidationError; 17 import org.monetdb.mcl.net.ValidationError;
17 18
18 import java.net.URISyntaxException; 19 import java.net.URISyntaxException;
19 import java.sql.Connection; 20 import java.sql.Connection;
137 * 138 *
138 * The getPropertyInfo method is intended to allow a generic GUI tool to 139 * The getPropertyInfo method is intended to allow a generic GUI tool to
139 * discover what properties it should prompt a human for in order to get 140 * discover what properties it should prompt a human for in order to get
140 * enough information to connect to a database. Note that depending on the 141 * enough information to connect to a database. Note that depending on the
141 * values the human has supplied so far, additional values may become 142 * values the human has supplied so far, additional values may become
142 * necessary, so it may be necessary to iterate though several calls to the 143 * necessary, so it may be necessary to iterate through several calls to the
143 * getPropertyInfo method. 144 * getPropertyInfo method.
144 * 145 *
145 * @param url the URL of the database to which to connect 146 * @param url the URL of the database to which to connect
146 * @param info a proposed list of tag/value pairs that will be sent on 147 * @param info a proposed list of tag/value pairs that will be sent on
147 * connect open 148 * connect open
152 @Override 153 @Override
153 public DriverPropertyInfo[] getPropertyInfo(final String url, final Properties info) { 154 public DriverPropertyInfo[] getPropertyInfo(final String url, final Properties info) {
154 if (!acceptsURL(url)) 155 if (!acceptsURL(url))
155 return null; 156 return null;
156 157
157 final String[] boolean_choices = new String[] { "true", "false" }; 158 // delegate to mcl.net.Parameters enum class, which maintains all connection properties
158 final DriverPropertyInfo[] dpi = new DriverPropertyInfo[10]; // we currently support 10 connection properties 159 return Parameter.getPropertyInfo(info, url.startsWith("jdbc:monetdbs:"));
159
160 DriverPropertyInfo prop = new DriverPropertyInfo("user", info != null ? info.getProperty("user") : null);
161 prop.required = true;
162 prop.description = "The user loginname to use when authenticating on the database server";
163 dpi[0] = prop;
164
165 prop = new DriverPropertyInfo("password", info != null ? info.getProperty("password") : null);
166 prop.required = true;
167 prop.description = "The password to use when authenticating on the database server";
168 dpi[1] = prop;
169
170 prop = new DriverPropertyInfo("debug", "false");
171 prop.required = false;
172 prop.description = "Whether or not to create a log file for debugging purposes";
173 prop.choices = boolean_choices;
174 dpi[2] = prop;
175
176 prop = new DriverPropertyInfo("logfile", null);
177 prop.required = false;
178 prop.description = "The filename to write the debug log to. Only takes effect if debug is set to true. If the file exists, an incrementing number is added, till the filename is unique.";
179 dpi[3] = prop;
180
181 prop = new DriverPropertyInfo("language", "sql");
182 prop.required = false;
183 prop.description = "What language to use for MonetDB conversations (experts only)";
184 prop.choices = new String[] { "sql", "mal" };
185 dpi[4] = prop;
186
187 prop = new DriverPropertyInfo("hash", null);
188 prop.required = false;
189 prop.description = "Force the use of the given hash algorithm (SHA512 or SHA384 or SHA256 or SHA1) during challenge response";
190 prop.choices = new String[] { "SHA512", "SHA384", "SHA256", "SHA1" };
191 dpi[5] = prop;
192
193 prop = new DriverPropertyInfo("treat_blob_as_binary", "true");
194 prop.required = false;
195 prop.description = "Should blob columns be mapped to Types.VARBINARY instead of Types.BLOB in ResultSets and PreparedStatements"; // recommend for increased performance due to less overhead
196 prop.choices = boolean_choices;
197 dpi[6] = prop;
198
199 prop = new DriverPropertyInfo("treat_clob_as_varchar", "true");
200 prop.required = false;
201 prop.description = "Should clob columns be mapped to Types.VARCHAR instead of Types.CLOB in ResultSets and PreparedStatements"; // recommend for increased performance due to less overhead
202 prop.choices = boolean_choices;
203 dpi[7] = prop;
204
205 prop = new DriverPropertyInfo("so_timeout", "0");
206 prop.required = false;
207 prop.description = "Defines the maximum time to wait in milliseconds on a blocking read socket call"; // this corresponds to the Connection.setNetworkTimeout() method introduced in JDBC 4.1
208 dpi[8] = prop;
209
210 prop = new DriverPropertyInfo("autocommit", "true");
211 prop.required = false;
212 prop.description = "Whether the connection should start in auto-commit mode";
213 prop.choices = boolean_choices;
214 dpi[9] = prop;
215
216 return dpi;
217 } 160 }
218 161
219 /** 162 /**
220 * Reports whether this driver is a genuine JDBC Compliant&trade; driver. A 163 * Reports whether this driver is a genuine JDBC Compliant&trade; driver. A
221 * driver may only report true here if it passes the JDBC compliance tests; 164 * driver may only report true here if it passes the JDBC compliance tests;