JDBC cleaning 2
* Remove needless checks for JDBC41 and 42
* Refactor some code from using Vector/Hashtable
* Some additional formatting / renaming
diff --git a/appserver/jdbc/jdbc-ra/jdbc-core/src/main/java/com/sun/gjc/common/DataSourceObjectBuilder.java b/appserver/jdbc/jdbc-ra/jdbc-core/src/main/java/com/sun/gjc/common/DataSourceObjectBuilder.java
index a6fb3e9..e6b6ff8 100644
--- a/appserver/jdbc/jdbc-ra/jdbc-core/src/main/java/com/sun/gjc/common/DataSourceObjectBuilder.java
+++ b/appserver/jdbc/jdbc-ra/jdbc-core/src/main/java/com/sun/gjc/common/DataSourceObjectBuilder.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2022 Contributors to the Eclipse Foundation.
* Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
@@ -16,15 +17,37 @@
package com.sun.gjc.common;
-import static java.util.logging.Level.FINEST;
+import static com.sun.gjc.common.DataSourceSpec.CLASSNAME;
+import static com.sun.gjc.common.DataSourceSpec.DATABASENAME;
+import static com.sun.gjc.common.DataSourceSpec.DATASOURCENAME;
+import static com.sun.gjc.common.DataSourceSpec.DELIMITER;
+import static com.sun.gjc.common.DataSourceSpec.DESCRIPTION;
+import static com.sun.gjc.common.DataSourceSpec.DRIVERPROPERTIES;
+import static com.sun.gjc.common.DataSourceSpec.ESCAPECHARACTER;
+import static com.sun.gjc.common.DataSourceSpec.INITIALPOOLSIZE;
+import static com.sun.gjc.common.DataSourceSpec.LOGINTIMEOUT;
+import static com.sun.gjc.common.DataSourceSpec.LOGWRITER;
+import static com.sun.gjc.common.DataSourceSpec.MAXIDLETIME;
+import static com.sun.gjc.common.DataSourceSpec.MAXPOOLSIZE;
+import static com.sun.gjc.common.DataSourceSpec.MAXSTATEMENTS;
+import static com.sun.gjc.common.DataSourceSpec.MINPOOLSIZE;
+import static com.sun.gjc.common.DataSourceSpec.NETWORKPROTOCOL;
+import static com.sun.gjc.common.DataSourceSpec.PASSWORD;
+import static com.sun.gjc.common.DataSourceSpec.PORTNUMBER;
+import static com.sun.gjc.common.DataSourceSpec.PROPERTYCYCLE;
+import static com.sun.gjc.common.DataSourceSpec.ROLENAME;
+import static com.sun.gjc.common.DataSourceSpec.SERVERNAME;
+import static com.sun.gjc.common.DataSourceSpec.USERNAME;
+import static java.util.Arrays.asList;
+import static java.util.logging.Level.SEVERE;
import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-import java.util.Hashtable;
+import java.util.HashMap;
+import java.util.List;
import java.util.Locale;
-import java.util.Vector;
-import java.util.logging.Level;
+import java.util.Map;
import java.util.logging.Logger;
import org.glassfish.internal.api.ClassLoaderHierarchy;
@@ -52,11 +75,7 @@
private static Logger _logger = LogDomains.getLogger(MethodExecutor.class, LogDomains.RSR_LOGGER);
private static final StringManager sm = StringManager.getManager(DataSourceObjectBuilder.class);
- private static boolean jdbc40 = detectJDBC40();
- private static boolean jdbc41 = detectJDBC41();
-
private DataSourceSpec spec;
- private Hashtable driverProperties;
private MethodExecutor executor;
/**
@@ -77,71 +96,71 @@
* issue in executing some method.
*/
public Object constructDataSourceObject() throws ResourceException {
- driverProperties = parseDriverProperties(spec, true);
+ Map<String, List<String>> driverProperties = parseDriverProperties(spec, true);
Object dataSourceObject = getDataSourceObject();
- Method[] methods = dataSourceObject.getClass().getMethods();
- for (int i = 0; i < methods.length; i++) {
- String methodName = methods[i].getName();
+
+ for (Method method : dataSourceObject.getClass().getMethods()) {
+ String methodName = method.getName();
+
// Check for driver properties first since some jdbc properties
// may be supported in form of driver properties
if (driverProperties.containsKey(methodName.toUpperCase(Locale.getDefault()))) {
- Vector values = (Vector) driverProperties.get(methodName.toUpperCase(Locale.getDefault()));
- executor.runMethod(methods[i], dataSourceObject, values);
+ executor.runMethod(method, dataSourceObject, driverProperties.get(methodName.toUpperCase(Locale.getDefault())));
+
} else if (methodName.equalsIgnoreCase("setUser")) {
- executor.runJavaBeanMethod(spec.getDetail(DataSourceSpec.USERNAME), methods[i], dataSourceObject);
+ executor.runJavaBeanMethod(spec.getDetail(USERNAME), method, dataSourceObject);
} else if (methodName.equalsIgnoreCase("setPassword")) {
- executor.runJavaBeanMethod(spec.getDetail(DataSourceSpec.PASSWORD), methods[i], dataSourceObject);
+ executor.runJavaBeanMethod(spec.getDetail(PASSWORD), method, dataSourceObject);
} else if (methodName.equalsIgnoreCase("setLoginTimeOut")) {
- executor.runJavaBeanMethod(spec.getDetail(DataSourceSpec.LOGINTIMEOUT), methods[i], dataSourceObject);
+ executor.runJavaBeanMethod(spec.getDetail(LOGINTIMEOUT), method, dataSourceObject);
} else if (methodName.equalsIgnoreCase("setLogWriter")) {
- executor.runJavaBeanMethod(spec.getDetail(DataSourceSpec.LOGWRITER), methods[i], dataSourceObject);
+ executor.runJavaBeanMethod(spec.getDetail(LOGWRITER), method, dataSourceObject);
} else if (methodName.equalsIgnoreCase("setDatabaseName")) {
- executor.runJavaBeanMethod(spec.getDetail(DataSourceSpec.DATABASENAME), methods[i], dataSourceObject);
+ executor.runJavaBeanMethod(spec.getDetail(DATABASENAME), method, dataSourceObject);
} else if (methodName.equalsIgnoreCase("setDataSourceName")) {
- executor.runJavaBeanMethod(spec.getDetail(DataSourceSpec.DATASOURCENAME), methods[i], dataSourceObject);
+ executor.runJavaBeanMethod(spec.getDetail(DATASOURCENAME), method, dataSourceObject);
} else if (methodName.equalsIgnoreCase("setDescription")) {
- executor.runJavaBeanMethod(spec.getDetail(DataSourceSpec.DESCRIPTION), methods[i], dataSourceObject);
+ executor.runJavaBeanMethod(spec.getDetail(DESCRIPTION), method, dataSourceObject);
} else if (methodName.equalsIgnoreCase("setNetworkProtocol")) {
- executor.runJavaBeanMethod(spec.getDetail(DataSourceSpec.NETWORKPROTOCOL), methods[i],
- dataSourceObject);
+ executor.runJavaBeanMethod(spec.getDetail(NETWORKPROTOCOL), method, dataSourceObject);
} else if (methodName.equalsIgnoreCase("setPortNumber")) {
- executor.runJavaBeanMethod(spec.getDetail(DataSourceSpec.PORTNUMBER), methods[i], dataSourceObject);
+ executor.runJavaBeanMethod(spec.getDetail(PORTNUMBER), method, dataSourceObject);
} else if (methodName.equalsIgnoreCase("setRoleName")) {
- executor.runJavaBeanMethod(spec.getDetail(DataSourceSpec.ROLENAME), methods[i], dataSourceObject);
+ executor.runJavaBeanMethod(spec.getDetail(ROLENAME), method, dataSourceObject);
} else if (methodName.equalsIgnoreCase("setServerName")) {
- executor.runJavaBeanMethod(spec.getDetail(DataSourceSpec.SERVERNAME), methods[i], dataSourceObject);
+ executor.runJavaBeanMethod(spec.getDetail(SERVERNAME), method, dataSourceObject);
} else if (methodName.equalsIgnoreCase("setMaxStatements")) {
- executor.runJavaBeanMethod(spec.getDetail(DataSourceSpec.MAXSTATEMENTS), methods[i], dataSourceObject);
+ executor.runJavaBeanMethod(spec.getDetail(MAXSTATEMENTS), method, dataSourceObject);
} else if (methodName.equalsIgnoreCase("setInitialPoolSize")) {
- executor.runJavaBeanMethod(spec.getDetail(DataSourceSpec.INITIALPOOLSIZE), methods[i],
- dataSourceObject);
+ executor.runJavaBeanMethod(spec.getDetail(INITIALPOOLSIZE), method, dataSourceObject);
} else if (methodName.equalsIgnoreCase("setMinPoolSize")) {
- executor.runJavaBeanMethod(spec.getDetail(DataSourceSpec.MINPOOLSIZE), methods[i], dataSourceObject);
+ executor.runJavaBeanMethod(spec.getDetail(MINPOOLSIZE), method, dataSourceObject);
} else if (methodName.equalsIgnoreCase("setMaxPoolSize")) {
- executor.runJavaBeanMethod(spec.getDetail(DataSourceSpec.MAXPOOLSIZE), methods[i], dataSourceObject);
+ executor.runJavaBeanMethod(spec.getDetail(MAXPOOLSIZE), method, dataSourceObject);
} else if (methodName.equalsIgnoreCase("setMaxIdleTime")) {
- executor.runJavaBeanMethod(spec.getDetail(DataSourceSpec.MAXIDLETIME), methods[i], dataSourceObject);
+ executor.runJavaBeanMethod(spec.getDetail(MAXIDLETIME), method, dataSourceObject);
} else if (methodName.equalsIgnoreCase("setPropertyCycle")) {
- executor.runJavaBeanMethod(spec.getDetail(DataSourceSpec.PROPERTYCYCLE), methods[i], dataSourceObject);
+ executor.runJavaBeanMethod(spec.getDetail(PROPERTYCYCLE), method, dataSourceObject);
}
}
+
return dataSourceObject;
}
@@ -155,13 +174,13 @@
* @throws ResourceException If delimiter is not provided and property string is
* not null.
*/
- public Hashtable parseDriverProperties(DataSourceSpec spec, boolean returnUpperCase) throws ResourceException {
- String delim = spec.getDetail(DataSourceSpec.DELIMITER);
- String escape = spec.getDetail(DataSourceSpec.ESCAPECHARACTER);
- String prop = spec.getDetail(DataSourceSpec.DRIVERPROPERTIES);
+ public Map<String, List<String>> parseDriverProperties(DataSourceSpec spec, boolean returnUpperCase) throws ResourceException {
+ String delim = spec.getDetail(DELIMITER);
+ String escape = spec.getDetail(ESCAPECHARACTER);
+ String prop = spec.getDetail(DRIVERPROPERTIES);
if (prop == null || prop.trim().equals("")) {
- return new Hashtable();
+ return new HashMap<>();
}
if (delim == null || delim.equals("")) {
@@ -184,17 +203,18 @@
* @param delimiter delimiter
* @return Hashtable
*/
- public Hashtable parseDriverProperties(String values, String escape, String delimiter, boolean returnUpperCase) {
- Hashtable result = new Hashtable();
+ public Map<String, List<String>> parseDriverProperties(String values, String escape, String delimiter, boolean returnUpperCase) {
+ Map<String, List<String>> parsedDriverProperties = new HashMap<>();
String parsedValue = "";
String name = "";
- String value = "";
+
char escapeChar = escape.charAt(0);
char delimiterChar = delimiter.charAt(0);
while (values.length() > 0) {
if (values.charAt(0) == delimiterChar) {
if (values.length() > 1 && values.charAt(1) == delimiterChar) {
if (values.length() > 2 && values.charAt(2) == delimiterChar) {
+
// Check for first property that does not have a value
// There is no value specified for this property.
// Store the name or it will be lost
@@ -203,13 +223,13 @@
} else {
name = parsedValue;
}
+
// no value specified for value
parsedValue = "";
}
- value = parsedValue;
- Vector v = new Vector();
- v.add(value);
- result.put(name, v);
+
+ parsedDriverProperties.put(name, asList(parsedValue));
+
parsedValue = "";
values = values.substring(2);
} else {
@@ -234,7 +254,7 @@
}
}
- return result;
+ return parsedDriverProperties;
}
/**
@@ -245,72 +265,30 @@
* not set properly.
*/
private Object getDataSourceObject() throws ResourceException {
- String className = spec.getDetail(DataSourceSpec.CLASSNAME);
+ String className = spec.getDetail(CLASSNAME);
try {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
Class<?> dataSourceClass;
try {
- dataSourceClass = Class.forName(className, true, cl);
+ dataSourceClass = Class.forName(className, true, classLoader);
} catch (ClassNotFoundException cnfe) {
// OSGi-ed apps can't see lib dir, so try using CommonClassLoader
- cl = Globals.get(ClassLoaderHierarchy.class).getCommonClassLoader();
- dataSourceClass = Class.forName(className, true, cl);
+ classLoader = Globals.get(ClassLoaderHierarchy.class).getCommonClassLoader();
+ dataSourceClass = Class.forName(className, true, classLoader);
}
return dataSourceClass.getDeclaredConstructor().newInstance();
} catch (ClassNotFoundException cnfe) {
- _logger.log(Level.SEVERE, "jdbc.exc_cnfe_ds", cnfe);
+ _logger.log(SEVERE, "jdbc.exc_cnfe_ds", cnfe);
throw new ResourceException(sm.getString("dsob.class_not_found", className), cnfe);
} catch (InstantiationException | NoSuchMethodException | InvocationTargetException ce) {
- _logger.log(Level.SEVERE, "jdbc.exc_inst", className);
+ _logger.log(SEVERE, "jdbc.exc_inst", className);
throw new ResourceException(sm.getString("dsob.error_instantiating", className), ce);
} catch (IllegalAccessException ce) {
- _logger.log(Level.SEVERE, "jdbc.exc_acc_inst", className);
+ _logger.log(SEVERE, "jdbc.exc_acc_inst", className);
throw new ResourceException(sm.getString("dsob.access_error", className), ce);
}
}
- public static boolean isJDBC40() {
- return jdbc40;
- }
-
- public static boolean isJDBC41() {
- return jdbc41;
- }
-
- /**
- * Check whether the jdbc api version is 4.0 or not.
- *
- * @return boolean
- */
- private static boolean detectJDBC40() {
- boolean jdbc40 = false;
- try {
- Class.forName("java.sql.Wrapper");
- jdbc40 = true;
- } catch (ClassNotFoundException cnfe) {
- _logger.log(FINEST, "could not find Wrapper(available in jdbc-40), jdk supports only jdbc-30");
- }
-
- return jdbc40;
- }
-
- /**
- * Detect if jdbc api version is 4.1 or not
- *
- * @return boolean
- */
- private static boolean detectJDBC41() {
- boolean jdbc41 = false;
- try {
- Class.forName("java.sql.PseudoColumnUsage");
- jdbc41 = true;
- } catch (ClassNotFoundException cnfe) {
- _logger.log(FINEST, "could not find PseudoColumnUsage(enum available in jdbc-41),"
- + " jdk supports jdbc-40 or lesser");
- }
-
- return jdbc41;
- }
}
diff --git a/appserver/jdbc/jdbc-ra/jdbc-core/src/main/java/com/sun/gjc/spi/DMManagedConnectionFactory.java b/appserver/jdbc/jdbc-ra/jdbc-core/src/main/java/com/sun/gjc/spi/DMManagedConnectionFactory.java
index ea7f356..feadb2c 100644
--- a/appserver/jdbc/jdbc-ra/jdbc-core/src/main/java/com/sun/gjc/spi/DMManagedConnectionFactory.java
+++ b/appserver/jdbc/jdbc-ra/jdbc-core/src/main/java/com/sun/gjc/spi/DMManagedConnectionFactory.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2022 Contributors to the Eclipse Foundation.
* Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
@@ -16,6 +17,11 @@
package com.sun.gjc.spi;
+import static com.sun.gjc.common.DataSourceSpec.CLASSNAME;
+import static com.sun.gjc.common.DataSourceSpec.LOGINTIMEOUT;
+import static com.sun.gjc.common.DataSourceSpec.PASSWORD;
+import static com.sun.gjc.common.DataSourceSpec.URL;
+import static com.sun.gjc.common.DataSourceSpec.USERNAME;
import static com.sun.gjc.util.SecurityUtils.getPasswordCredential;
import static java.util.logging.Level.FINE;
import static java.util.logging.Level.FINEST;
@@ -24,18 +30,15 @@
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
-import java.util.Hashtable;
+import java.util.List;
import java.util.Map;
import java.util.Properties;
-import java.util.Set;
-import java.util.Vector;
import java.util.logging.Logger;
import javax.security.auth.Subject;
import javax.sql.DataSource;
import com.sun.gjc.common.DataSourceObjectBuilder;
-import com.sun.gjc.common.DataSourceSpec;
import com.sun.gjc.spi.base.AbstractDataSource;
import com.sun.gjc.spi.base.ConnectionHolder;
import com.sun.logging.LogDomains;
@@ -55,7 +58,11 @@
* @author Evani Sai Surya Kiran
* @version 1.0, 02/07/31
*/
-@ConnectionDefinition(connectionFactory = DataSource.class, connectionFactoryImpl = AbstractDataSource.class, connection = Connection.class, connectionImpl = ConnectionHolder.class)
+@ConnectionDefinition(
+ connectionFactory = DataSource.class,
+ connectionFactoryImpl = AbstractDataSource.class,
+ connection = Connection.class,
+ connectionImpl = ConnectionHolder.class)
public class DMManagedConnectionFactory extends ManagedConnectionFactoryImpl {
private static Logger _logger = LogDomains.getLogger(DMManagedConnectionFactory.class, LogDomains.RSR_LOGGER);
@@ -79,6 +86,7 @@
* @throws SecurityException if there ino <code>PasswordCredential</code> object
* satisfying this request
*/
+ @Override
public ManagedConnection createManagedConnection(Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException {
logFine("In createManagedConnection");
@@ -89,10 +97,10 @@
PasswordCredential passwordCredential = getPasswordCredential(this, subject, cxRequestInfo);
try {
- Class.forName(spec.getDetail(DataSourceSpec.CLASSNAME));
+ Class.forName(spec.getDetail(CLASSNAME));
} catch (ClassNotFoundException cnfe) {
_logger.log(SEVERE, "jdbc.exc_cnfe", cnfe);
- throw new ResourceException("The driver could not be loaded: " + spec.getDetail(DataSourceSpec.CLASSNAME));
+ throw new ResourceException("The driver could not be loaded: " + spec.getDetail(CLASSNAME));
}
Connection connection = null;
@@ -102,22 +110,21 @@
// Will return a set of properties that would have setURL and <url> as objects
// Get a set of normal case properties
- Hashtable properties = dataSourceObjectBuilder.parseDriverProperties(spec, false);
- Set<Map.Entry<String, Vector>> entries = properties.entrySet();
- for (Map.Entry<String, Vector> entry : entries) {
+ Map<String, List<String>> properties = dataSourceObjectBuilder.parseDriverProperties(spec, false);
+ for (Map.Entry<String, List<String>> entry : properties.entrySet()) {
String value = "";
- String key = entry.getKey();
- Vector values = entry.getValue();
+ List<String> values = entry.getValue();
+
if (!values.isEmpty() && values.size() == 1) {
- value = (String) values.firstElement();
+ value = values.get(0);
} else if (values.size() > 1) {
- logFine("More than one value for key : " + key);
+ logFine("More than one value for key : " + entry.getKey());
}
- String prop = getParsedKey(key);
- driverProps.put(prop, value);
- if (prop.equalsIgnoreCase("URL")) {
- if (spec.getDetail(DataSourceSpec.URL) == null) {
+ String parsedKey = getParsedKey(entry.getKey());
+ driverProps.put(parsedKey, value);
+ if (parsedKey.equalsIgnoreCase("URL")) {
+ if (spec.getDetail(URL) == null) {
setConnectionURL(value);
}
}
@@ -128,8 +135,8 @@
driverProps.setProperty("user", passwordCredential.getUserName());
driverProps.setProperty("password", new String(passwordCredential.getPassword()));
} else {
- String user = spec.getDetail(DataSourceSpec.USERNAME);
- String password = spec.getDetail(DataSourceSpec.PASSWORD);
+ String user = spec.getDetail(USERNAME);
+ String password = spec.getDetail(PASSWORD);
if (user != null) {
driverProps.setProperty("user", user);
}
@@ -138,7 +145,7 @@
}
}
- connection = DriverManager.getConnection(spec.getDetail(DataSourceSpec.URL), driverProps);
+ connection = DriverManager.getConnection(spec.getDetail(URL), driverProps);
} catch (SQLException sqle) {
_logger.log(SEVERE, "jdbc.exc_create_mc", sqle);
@@ -201,10 +208,11 @@
* @param loginTimeOut <code>String</code>
* @see <code>getLoginTimeOut</code>
*/
+ @Override
public void setLoginTimeOut(String loginTimeOut) {
try {
DriverManager.setLoginTimeout(Integer.parseInt(loginTimeOut));
- spec.setDetail(DataSourceSpec.LOGINTIMEOUT, loginTimeOut);
+ spec.setDetail(LOGINTIMEOUT, loginTimeOut);
} catch (Exception e) {
if (debug) {
_logger.log(FINE, "jdbc.exc_caught_ign", e.getMessage());
@@ -220,15 +228,15 @@
@ConfigProperty(type = String.class, defaultValue = "org.apache.derby.jdbc.ClientDriver")
@Override
public void setClassName(String className) {
- spec.setDetail(DataSourceSpec.CLASSNAME, className);
+ spec.setDetail(CLASSNAME, className);
}
public void setURL(String url) {
- spec.setDetail(DataSourceSpec.URL, url);
+ spec.setDetail(URL, url);
}
public String getURL() {
- return spec.getDetail(DataSourceSpec.URL);
+ return spec.getDetail(URL);
}
/**
@@ -238,7 +246,7 @@
* @see <code>getConnectionURL</code>
*/
public void setConnectionURL(String url) {
- spec.setDetail(DataSourceSpec.URL, url);
+ spec.setDetail(URL, url);
}
/**
@@ -248,9 +256,10 @@
* @see <code>setConnectionURL</code>
*/
public String getConnectionURL() {
- return spec.getDetail(DataSourceSpec.URL);
+ return spec.getDetail(URL);
}
+ @Override
public Object getDataSource() throws ResourceException {
return null;
}
@@ -264,6 +273,7 @@
* @return true if the property sets of both the
* <code>ManagedConnectionFactory</code> objects are the same false otherwise
*/
+ @Override
public boolean equals(Object other) {
logFine("In equals");
diff --git a/appserver/jdbc/jdbc-ra/jdbc-core/src/main/java/com/sun/gjc/spi/JdbcObjectsFactory.java b/appserver/jdbc/jdbc-ra/jdbc-core/src/main/java/com/sun/gjc/spi/JdbcObjectsFactory.java
index 899e581..d65144f 100644
--- a/appserver/jdbc/jdbc-ra/jdbc-core/src/main/java/com/sun/gjc/spi/JdbcObjectsFactory.java
+++ b/appserver/jdbc/jdbc-ra/jdbc-core/src/main/java/com/sun/gjc/spi/JdbcObjectsFactory.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2022 Contributors to the Eclipse Foundation.
* Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
@@ -30,7 +31,6 @@
import org.glassfish.api.jdbc.SQLTraceRecord;
-import com.sun.gjc.common.DataSourceObjectBuilder;
import com.sun.gjc.spi.base.ConnectionHolder;
import com.sun.gjc.util.SQLTraceDelegator;
import com.sun.logging.LogDomains;
@@ -47,32 +47,20 @@
protected final static Logger _logger = LogDomains.getLogger(JdbcObjectsFactory.class, LogDomains.RSR_LOGGER);
/**
- * Returns JDBC Object Factory for JDBC 3.0 or JDBC 4.0 depending upon the jdbc
- * version available in JDK.
+ * Returns JDBC Object Factory
*
* @return JdbcObjectsFactory
*/
public static JdbcObjectsFactory getInstance() {
- boolean jdbc40 = DataSourceObjectBuilder.isJDBC40();
-
- JdbcObjectsFactory factory = null;
try {
- if (jdbc40) {
- factory = (JdbcObjectsFactory)
- Class.forName("com.sun.gjc.spi.jdbc40.Jdbc40ObjectsFactory")
- .getDeclaredConstructor()
- .newInstance();
- } else {
- factory = (JdbcObjectsFactory)
- Class.forName("com.sun.gjc.spi.jdbc30.Jdbc30ObjectsFactory")
- .getDeclaredConstructor()
- .newInstance();
- }
+ return(JdbcObjectsFactory)
+ Class.forName("com.sun.gjc.spi.jdbc40.Jdbc40ObjectsFactory")
+ .getDeclaredConstructor()
+ .newInstance();
} catch (Exception e) {
_logger.log(WARNING, "jdbc.jdbc_factory_class_load_exception", e);
+ return null;
}
-
- return factory;
}
/**
@@ -112,6 +100,7 @@
protected <T> T getProxyObject(final Object actualObject, Class<T>[] ifaces, final SQLTraceDelegator sqlTraceDelegator) throws Exception {
InvocationHandler invocationHandler = new InvocationHandler() {
+ @Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
SQLTraceRecord record = new SQLTraceRecord();
record.setMethodName(method.getName());
diff --git a/appserver/jdbc/jdbc-ra/jdbc-core/src/main/java/com/sun/gjc/spi/ManagedConnectionFactoryImpl.java b/appserver/jdbc/jdbc-ra/jdbc-core/src/main/java/com/sun/gjc/spi/ManagedConnectionFactoryImpl.java
index 998a02f..9a61c45 100644
--- a/appserver/jdbc/jdbc-ra/jdbc-core/src/main/java/com/sun/gjc/spi/ManagedConnectionFactoryImpl.java
+++ b/appserver/jdbc/jdbc-ra/jdbc-core/src/main/java/com/sun/gjc/spi/ManagedConnectionFactoryImpl.java
@@ -1,6 +1,6 @@
/*
+ * Copyright (c) 2021, 2022 Contributors to the Eclipse Foundation.
* Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2021 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -17,9 +17,15 @@
package com.sun.gjc.spi;
+import static com.sun.gjc.common.DataSourceSpec.CONNECTIONVALIDATIONREQUIRED;
+import static com.sun.gjc.common.DataSourceSpec.GUARANTEEISOLATIONLEVEL;
+import static com.sun.gjc.common.DataSourceSpec.TRANSACTIONISOLATION;
+import static com.sun.gjc.common.DataSourceSpec.VALIDATIONCLASSNAME;
+import static com.sun.gjc.common.DataSourceSpec.VALIDATIONMETHOD;
import static com.sun.gjc.util.SecurityUtils.getPasswordCredential;
import static com.sun.gjc.util.SecurityUtils.isPasswordCredentialEqual;
import static java.util.logging.Level.FINE;
+import static java.util.logging.Level.INFO;
import static java.util.logging.Level.SEVERE;
import java.io.Externalizable;
@@ -118,6 +124,7 @@
* @return Generic JDBC Connector implementation of
* <code>javax.sql.DataSource</code>
*/
+ @Override
public Object createConnectionFactory() {
logFine("In createConnectionFactory()");
return jdbcObjectsFactory.getDataSourceInstance(this, null);
@@ -132,6 +139,7 @@
* @return Generic JDBC Connector implementation of
* <code>javax.sql.DataSource</code>
*/
+ @Override
public Object createConnectionFactory(ConnectionManager connectionManager) {
logFine("In createConnectionFactory(jakarta.resource.spi.ConnectionManager cxManager)");
@@ -162,6 +170,7 @@
* @throws ResourceException if there is an error in allocating the physical
* connection
*/
+ @Override
public abstract ManagedConnection createManagedConnection(Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException;
/**
@@ -174,6 +183,7 @@
* <code>ManagedConnectionFactoryImpl</code> objects are the same false
* otherwise
*/
+ @Override
public abstract boolean equals(Object other);
/**
@@ -184,6 +194,7 @@
* <code>ManagedConnectionFactoryImpl</code> instance
* @see <code>setLogWriter</code>
*/
+ @Override
public java.io.PrintWriter getLogWriter() {
return logWriter;
}
@@ -196,6 +207,7 @@
* <code>ManagedConnectionFactoryImpl</code> instance
* @see <code>setResourceAdapter</code>
*/
+ @Override
public jakarta.resource.spi.ResourceAdapter getResourceAdapter() {
logFine("In getResourceAdapter");
return resourceAdapter;
@@ -206,6 +218,7 @@
*
* @return hash code for this <code>ManagedConnectionFactoryImpl</code>
*/
+ @Override
public int hashCode() {
logFine("In hashCode");
return spec.hashCode();
@@ -227,6 +240,7 @@
* <code>Subject</code> parameter or the <code>Set</code> of
* <code>ManagedConnection</code> objects passed by the application server
*/
+ @Override
public ManagedConnection matchManagedConnections(Set connectionSet, Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException {
logFine("In matchManagedConnections");
@@ -267,6 +281,7 @@
* @return a set of invalid <code>ManagedConnection</code> objects.
* @throws ResourceException generic exception.
*/
+ @Override
public Set getInvalidConnections(Set connectionSet) throws ResourceException {
Iterator iter = connectionSet.iterator();
Set<ManagedConnectionImpl> invalidConnections = new HashSet<ManagedConnectionImpl>();
@@ -288,39 +303,41 @@
* Checks if a <code>ManagedConnection</code> is to be validated or not and
* validates it or returns.
*
- * @param mc <code>ManagedConnection</code> to be validated
+ * @param managedConnectionImpl <code>ManagedConnection</code> to be validated
* @throws ResourceException if the connection is not valid or if validation
* method is not proper
*/
- void isValid(ManagedConnectionImpl mc) throws ResourceException {
- if (mc == null || mc.isTransactionInProgress()) {
+ void isValid(ManagedConnectionImpl managedConnectionImpl) throws ResourceException {
+ if (managedConnectionImpl == null || managedConnectionImpl.isTransactionInProgress()) {
return;
}
- String conVal = spec.getDetail(DataSourceSpec.CONNECTIONVALIDATIONREQUIRED);
+ String conVal = spec.getDetail(CONNECTIONVALIDATIONREQUIRED);
- boolean connectionValidationRequired = (conVal == null) ? false
- : Boolean.valueOf(conVal.toLowerCase(Locale.getDefault()));
+ boolean connectionValidationRequired = (conVal == null) ?
+ false :
+ Boolean.valueOf(conVal.toLowerCase(Locale.getDefault()));
if (!connectionValidationRequired) {
return;
}
- String validationMethod = spec.getDetail(DataSourceSpec.VALIDATIONMETHOD).toLowerCase(Locale.getDefault());
+ String validationMethod = spec.getDetail(VALIDATIONMETHOD).toLowerCase(Locale.getDefault());
- mc.checkIfValid();
+ managedConnectionImpl.checkIfValid();
+
/**
* The above call checks if the actual physical connection is usable or not.
*/
- java.sql.Connection con = mc.getActualConnection();
+ Connection connection = managedConnectionImpl.getActualConnection();
if (validationMethod.equals("custom-validation")) {
- isValidByCustomValidation(con, spec.getDetail(DataSourceSpec.VALIDATIONCLASSNAME));
+ isValidByCustomValidation(connection, spec.getDetail(VALIDATIONCLASSNAME));
} else if (validationMethod.equals("auto-commit")) {
- isValidByAutoCommit(con);
+ isValidByAutoCommit(connection);
} else if (validationMethod.equals("meta-data")) {
- isValidByMetaData(con);
+ isValidByMetaData(connection);
} else if (validationMethod.equals("table")) {
- isValidByTableQuery(con, spec.getDetail(DataSourceSpec.VALIDATIONTABLENAME));
+ isValidByTableQuery(connection, spec.getDetail(DataSourceSpec.VALIDATIONTABLENAME));
} else {
throw new ResourceException("The validation method is not proper");
}
@@ -330,26 +347,31 @@
* Checks if a <code>java.sql.Connection</code> is valid or not by doing a
* custom validation using the validation class name specified.
*
- * @param con <code>java.sql.Connection</code> to be validated
+ * @param connection <code>java.sql.Connection</code> to be validated
* @throws ResourceException if the connection is not valid
*/
- protected void isValidByCustomValidation(java.sql.Connection con, String validationClassName)
- throws ResourceException {
+ protected void isValidByCustomValidation(Connection connection, String validationClassName) throws ResourceException {
boolean isValid = false;
- if (con == null) {
+ if (connection == null) {
throw new ResourceException("The connection is not valid as " + "the connection is null");
}
try {
- Class validationClass = Thread.currentThread().getContextClassLoader().loadClass(validationClassName);
- ConnectionValidation valClass = (ConnectionValidation) validationClass.newInstance();
- isValid = valClass.isConnectionValid(con);
+ ConnectionValidation connectionValidation = (ConnectionValidation)
+ Thread.currentThread()
+ .getContextClassLoader()
+ .loadClass(validationClassName)
+ .getDeclaredConstructor()
+ .newInstance();
+
+ isValid = connectionValidation.isConnectionValid(connection);
} catch (Exception e) {
- _logger.log(Level.INFO, "jdbc.exc_custom_validation", validationClassName);
+ _logger.log(INFO, "jdbc.exc_custom_validation", validationClassName);
throw new ResourceException(e);
}
+
if (!isValid) {
- _logger.log(Level.INFO, "jdbc.exc_custom_validation", validationClassName);
+ _logger.log(INFO, "jdbc.exc_custom_validation", validationClassName);
throw new ResourceException("Custom validation detected invalid connection");
}
}
@@ -358,11 +380,11 @@
* Checks if a <code>java.sql.Connection</code> is valid or not by checking its
* auto commit property.
*
- * @param con <code>java.sql.Connection</code> to be validated
+ * @param connection <code>java.sql.Connection</code> to be validated
* @throws ResourceException if the connection is not valid
*/
- protected void isValidByAutoCommit(java.sql.Connection con) throws ResourceException {
- if (con == null) {
+ protected void isValidByAutoCommit(Connection connection) throws ResourceException {
+ if (connection == null) {
throw new ResourceException("The connection is not valid as " + "the connection is null");
}
@@ -377,18 +399,18 @@
// Also notice that some XA data sources will throw and exception if
// you try to call setAutoCommit, for them this method is not recommended
- boolean ac = con.getAutoCommit();
- if (ac) {
- con.setAutoCommit(false);
+ boolean autoCommit = connection.getAutoCommit();
+ if (autoCommit) {
+ connection.setAutoCommit(false);
} else {
- con.rollback(); // prevents uncompleted transaction exceptions
- con.setAutoCommit(true);
+ connection.rollback(); // prevents uncompleted transaction exceptions
+ connection.setAutoCommit(true);
}
- con.setAutoCommit(ac);
+ connection.setAutoCommit(autoCommit);
} catch (Exception sqle) {
- _logger.log(Level.INFO, "jdbc.exc_autocommit_validation");
+ _logger.log(INFO, "jdbc.exc_autocommit_validation");
throw new ResourceException(sqle);
}
}
@@ -397,18 +419,18 @@
* Checks if a <code>java.sql.Connection</code> is valid or not by checking its
* meta data.
*
- * @param con <code>java.sql.Connection</code> to be validated
+ * @param connection <code>java.sql.Connection</code> to be validated
* @throws ResourceException if the connection is not valid
*/
- protected void isValidByMetaData(java.sql.Connection con) throws ResourceException {
- if (con == null) {
+ protected void isValidByMetaData(Connection connection) throws ResourceException {
+ if (connection == null) {
throw new ResourceException("The connection is not valid as " + "the connection is null");
}
try {
- con.getMetaData();
+ connection.getMetaData();
} catch (Exception sqle) {
- _logger.log(Level.INFO, "jdbc.exc_metadata_validation");
+ _logger.log(INFO, "jdbc.exc_metadata_validation");
throw new ResourceException(sqle);
}
}
@@ -432,7 +454,7 @@
preparedStatement = connection.prepareStatement("SELECT COUNT(*) FROM " + tableName);
resultSet = preparedStatement.executeQuery();
} catch (Exception sqle) {
- _logger.log(Level.INFO, "jdbc.exc_table_validation", tableName);
+ _logger.log(INFO, "jdbc.exc_table_validation", tableName);
throw new ResourceException(sqle);
} finally {
try {
@@ -465,7 +487,7 @@
return;
}
- String tranIsolation = spec.getDetail(DataSourceSpec.TRANSACTIONISOLATION);
+ String tranIsolation = spec.getDetail(TRANSACTIONISOLATION);
if (tranIsolation != null && !tranIsolation.equals("")) {
int tranIsolationInt = getTransactionIsolationInt(tranIsolation);
try {
@@ -497,9 +519,9 @@
return;
}
- String transactionIsolation = spec.getDetail(DataSourceSpec.TRANSACTIONISOLATION);
+ String transactionIsolation = spec.getDetail(TRANSACTIONISOLATION);
if (transactionIsolation != null && !transactionIsolation.equals("")) {
- String guaranteeIsolationLevel = spec.getDetail(DataSourceSpec.GUARANTEEISOLATIONLEVEL);
+ String guaranteeIsolationLevel = spec.getDetail(GUARANTEEISOLATIONLEVEL);
if (guaranteeIsolationLevel != null && !guaranteeIsolationLevel.equals("")) {
boolean guarantee = Boolean.valueOf(guaranteeIsolationLevel.toLowerCase(Locale.getDefault()));
@@ -663,6 +685,7 @@
* @param out <code>PrintWriter</code> passed by the application server
* @see <code>getLogWriter</code>
*/
+ @Override
public void setLogWriter(java.io.PrintWriter out) {
logWriter = out;
}
@@ -674,6 +697,7 @@
* <code>ManagedConnectionFactoryImpl</code> instance
* @see <code>getResourceAdapter</code>
*/
+ @Override
public void setResourceAdapter(jakarta.resource.spi.ResourceAdapter ra) {
this.resourceAdapter = ra;
}
@@ -761,7 +785,7 @@
*/
@ConfigProperty(type = String.class, defaultValue = "")
public void setValidationMethod(String validationMethod) {
- spec.setDetail(DataSourceSpec.VALIDATIONMETHOD, validationMethod);
+ spec.setDetail(VALIDATIONMETHOD, validationMethod);
}
/**
@@ -770,7 +794,7 @@
* @return validation method
*/
public String getValidationMethod() {
- return spec.getDetail(DataSourceSpec.VALIDATIONMETHOD);
+ return spec.getDetail(VALIDATIONMETHOD);
}
/**
@@ -802,7 +826,7 @@
Class validationClass = Thread.currentThread().getContextClassLoader().loadClass(className);
boolean isAssignable = ConnectionValidation.class.isAssignableFrom(validationClass);
if (isAssignable) {
- spec.setDetail(DataSourceSpec.VALIDATIONCLASSNAME, className);
+ spec.setDetail(VALIDATIONCLASSNAME, className);
} else {
// Validation Failed
_logger.log(SEVERE, "jdbc.set_custom_validation_class_name_failure", className);
@@ -822,7 +846,7 @@
* @return table
*/
public String getValidationClassName() {
- return spec.getDetail(DataSourceSpec.VALIDATIONCLASSNAME);
+ return spec.getDetail(VALIDATIONCLASSNAME);
}
/**
@@ -832,7 +856,7 @@
*/
@ConfigProperty(type = String.class, defaultValue = "")
public void setTransactionIsolation(String trnIsolation) {
- spec.setDetail(DataSourceSpec.TRANSACTIONISOLATION, trnIsolation);
+ spec.setDetail(TRANSACTIONISOLATION, trnIsolation);
}
/**
@@ -841,7 +865,7 @@
* @return transaction isolation level
*/
public String getTransactionIsolation() {
- return spec.getDetail(DataSourceSpec.TRANSACTIONISOLATION);
+ return spec.getDetail(TRANSACTIONISOLATION);
}
/**
@@ -851,7 +875,7 @@
*/
@ConfigProperty(type = String.class, defaultValue = "")
public void setGuaranteeIsolationLevel(String guaranteeIsolation) {
- spec.setDetail(DataSourceSpec.GUARANTEEISOLATIONLEVEL, guaranteeIsolation);
+ spec.setDetail(GUARANTEEISOLATIONLEVEL, guaranteeIsolation);
}
/**
@@ -860,7 +884,7 @@
* @return isolation level guarantee
*/
public String getGuaranteeIsolationLevel() {
- return spec.getDetail(DataSourceSpec.GUARANTEEISOLATIONLEVEL);
+ return spec.getDetail(GUARANTEEISOLATIONLEVEL);
}
protected boolean isEqual(PasswordCredential pc, String user, String password) {
@@ -1434,9 +1458,11 @@
}
}
+ @Override
public void writeExternal(ObjectOutput out) throws IOException {
}
+ @Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
resourceAdapter = ResourceAdapterImpl.getInstance();
}
diff --git a/appserver/jdbc/jdbc-ra/jdbc-core/src/main/java/com/sun/gjc/spi/base/PreparedStatementWrapper.java b/appserver/jdbc/jdbc-ra/jdbc-core/src/main/java/com/sun/gjc/spi/base/PreparedStatementWrapper.java
index 40ad3d1..cb8a529 100644
--- a/appserver/jdbc/jdbc-ra/jdbc-core/src/main/java/com/sun/gjc/spi/base/PreparedStatementWrapper.java
+++ b/appserver/jdbc/jdbc-ra/jdbc-core/src/main/java/com/sun/gjc/spi/base/PreparedStatementWrapper.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2022 Contributors to the Eclipse Foundation.
* Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
@@ -16,7 +17,6 @@
package com.sun.gjc.spi.base;
-import static com.sun.gjc.common.DataSourceObjectBuilder.isJDBC41;
import java.io.InputStream;
import java.io.Reader;
@@ -37,7 +37,6 @@
import java.util.Calendar;
import java.util.logging.Level;
-import com.sun.gjc.common.DataSourceObjectBuilder;
import com.sun.gjc.util.ResultSetClosedEventListener;
/**
@@ -108,6 +107,7 @@
* @throws java.sql.SQLException if a database access error occurs or the SQL
* statement returns a <code>ResultSet</code> object
*/
+ @Override
public int executeUpdate() throws SQLException {
return preparedStatement.executeUpdate();
}
@@ -122,6 +122,7 @@
* @param sqlType the SQL type code defined in <code>java.sql.Types</code>
* @throws java.sql.SQLException if a database access error occurs
*/
+ @Override
public void setNull(int parameterIndex, int sqlType) throws SQLException {
preparedStatement.setNull(parameterIndex, sqlType);
}
@@ -135,6 +136,7 @@
* @param x the parameter value
* @throws java.sql.SQLException if a database access error occurs
*/
+ @Override
public void setBoolean(int parameterIndex, boolean x) throws SQLException {
preparedStatement.setBoolean(parameterIndex, x);
}
@@ -148,6 +150,7 @@
* @param x the parameter value
* @throws java.sql.SQLException if a database access error occurs
*/
+ @Override
public void setByte(int parameterIndex, byte x) throws SQLException {
preparedStatement.setByte(parameterIndex, x);
}
@@ -161,6 +164,7 @@
* @param x the parameter value
* @throws java.sql.SQLException if a database access error occurs
*/
+ @Override
public void setShort(int parameterIndex, short x) throws SQLException {
preparedStatement.setShort(parameterIndex, x);
}
@@ -174,6 +178,7 @@
* @param x the parameter value
* @throws java.sql.SQLException if a database access error occurs
*/
+ @Override
public void setInt(int parameterIndex, int x) throws SQLException {
preparedStatement.setInt(parameterIndex, x);
}
@@ -187,6 +192,7 @@
* @param x the parameter value
* @throws java.sql.SQLException if a database access error occurs
*/
+ @Override
public void setLong(int parameterIndex, long x) throws SQLException {
preparedStatement.setLong(parameterIndex, x);
}
@@ -200,6 +206,7 @@
* @param x the parameter value
* @throws java.sql.SQLException if a database access error occurs
*/
+ @Override
public void setFloat(int parameterIndex, float x) throws SQLException {
preparedStatement.setFloat(parameterIndex, x);
}
@@ -213,6 +220,7 @@
* @param x the parameter value
* @throws java.sql.SQLException if a database access error occurs
*/
+ @Override
public void setDouble(int parameterIndex, double x) throws SQLException {
preparedStatement.setDouble(parameterIndex, x);
}
@@ -226,6 +234,7 @@
* @param x the parameter value
* @throws java.sql.SQLException if a database access error occurs
*/
+ @Override
public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException {
preparedStatement.setBigDecimal(parameterIndex, x);
}
@@ -241,6 +250,7 @@
* @param x the parameter value
* @throws java.sql.SQLException if a database access error occurs
*/
+ @Override
public void setString(int parameterIndex, String x) throws SQLException {
preparedStatement.setString(parameterIndex, x);
}
@@ -255,6 +265,7 @@
* @param x the parameter value
* @throws java.sql.SQLException if a database access error occurs
*/
+ @Override
public void setBytes(int parameterIndex, byte x[]) throws SQLException {
preparedStatement.setBytes(parameterIndex, x);
}
@@ -268,6 +279,7 @@
* @param x the parameter value
* @throws java.sql.SQLException if a database access error occurs
*/
+ @Override
public void setDate(int parameterIndex, Date x) throws SQLException {
preparedStatement.setDate(parameterIndex, x);
}
@@ -281,6 +293,7 @@
* @param x the parameter value
* @throws java.sql.SQLException if a database access error occurs
*/
+ @Override
public void setTime(int parameterIndex, Time x) throws SQLException {
preparedStatement.setTime(parameterIndex, x);
}
@@ -294,6 +307,7 @@
* @param x the parameter value
* @throws java.sql.SQLException if a database access error occurs
*/
+ @Override
public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException {
preparedStatement.setTimestamp(parameterIndex, x);
}
@@ -315,6 +329,7 @@
* @param length the number of bytes in the stream
* @throws java.sql.SQLException if a database access error occurs
*/
+ @Override
public void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException {
preparedStatement.setAsciiStream(parameterIndex, x, length);
}
@@ -341,6 +356,7 @@
* @throws java.sql.SQLException if a database access error occurs
* @deprecated
*/
+ @Override
@Deprecated
public void setUnicodeStream(int parameterIndex, InputStream x, int length) throws SQLException {
preparedStatement.setUnicodeStream(parameterIndex, x, length);
@@ -362,6 +378,7 @@
* @param length the number of bytes in the stream
* @throws java.sql.SQLException if a database access error occurs
*/
+ @Override
public void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException {
preparedStatement.setBinaryStream(parameterIndex, x, length);
}
@@ -377,6 +394,7 @@
*
* @throws java.sql.SQLException if a database access error occurs
*/
+ @Override
public void clearParameters() throws SQLException {
preparedStatement.clearParameters();
}
@@ -413,6 +431,7 @@
* @throws java.sql.SQLException if a database access error occurs
* @see java.sql.Types
*/
+ @Override
public void setObject(int parameterIndex, Object x, int targetSqlType, int scale) throws SQLException {
preparedStatement.setObject(parameterIndex, x, targetSqlType, scale);
}
@@ -428,6 +447,7 @@
* to the database
* @throws java.sql.SQLException if a database access error occurs
*/
+ @Override
public void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException {
preparedStatement.setObject(parameterIndex, x, targetSqlType);
}
@@ -463,6 +483,7 @@
* @throws java.sql.SQLException if a database access error occurs or the type
* of the given object is ambiguous
*/
+ @Override
public void setObject(int parameterIndex, Object x) throws SQLException {
preparedStatement.setObject(parameterIndex, x);
}
@@ -490,6 +511,7 @@
* @see java.sql.Statement#getUpdateCount
* @see java.sql.Statement#getMoreResults
*/
+ @Override
public boolean execute() throws SQLException {
return preparedStatement.execute();
}
@@ -502,6 +524,7 @@
* @see java.sql.Statement#addBatch
* @since 1.2
*/
+ @Override
public void addBatch() throws SQLException {
preparedStatement.addBatch();
}
@@ -525,6 +548,7 @@
* @throws java.sql.SQLException if a database access error occurs
* @since 1.2
*/
+ @Override
public void setCharacterStream(int parameterIndex, Reader reader, int length) throws SQLException {
preparedStatement.setCharacterStream(parameterIndex, reader, length);
}
@@ -539,6 +563,7 @@
* @throws java.sql.SQLException if a database access error occurs
* @since 1.2
*/
+ @Override
public void setRef(int i, Ref x) throws SQLException {
preparedStatement.setRef(i, x);
}
@@ -553,6 +578,7 @@
* @throws java.sql.SQLException if a database access error occurs
* @since 1.2
*/
+ @Override
public void setBlob(int i, Blob x) throws SQLException {
preparedStatement.setBlob(i, x);
}
@@ -567,6 +593,7 @@
* @throws java.sql.SQLException if a database access error occurs
* @since 1.2
*/
+ @Override
public void setClob(int i, Clob x) throws SQLException {
preparedStatement.setClob(i, x);
}
@@ -582,6 +609,7 @@
* @throws java.sql.SQLException if a database access error occurs
* @since 1.2
*/
+ @Override
public void setArray(int i, Array x) throws SQLException {
preparedStatement.setArray(i, x);
}
@@ -608,6 +636,7 @@
* @throws java.sql.SQLException if a database access error occurs
* @since 1.2
*/
+ @Override
public ResultSetMetaData getMetaData() throws SQLException {
return preparedStatement.getMetaData();
}
@@ -629,6 +658,7 @@
* @throws java.sql.SQLException if a database access error occurs
* @since 1.2
*/
+ @Override
public void setDate(int parameterIndex, Date x, Calendar cal) throws SQLException {
preparedStatement.setDate(parameterIndex, x, cal);
}
@@ -650,6 +680,7 @@
* @throws java.sql.SQLException if a database access error occurs
* @since 1.2
*/
+ @Override
public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException {
preparedStatement.setTime(parameterIndex, x, cal);
}
@@ -671,6 +702,7 @@
* @throws java.sql.SQLException if a database access error occurs
* @since 1.2
*/
+ @Override
public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws SQLException {
preparedStatement.setTimestamp(parameterIndex, x, cal);
}
@@ -700,6 +732,7 @@
* @throws java.sql.SQLException if a database access error occurs
* @since 1.2
*/
+ @Override
public void setNull(int paramIndex, int sqlType, String typeName) throws SQLException {
preparedStatement.setNull(paramIndex, sqlType, typeName);
}
@@ -714,6 +747,7 @@
* @throws java.sql.SQLException if a database access error occurs
* @since 1.4
*/
+ @Override
public void setURL(int parameterIndex, URL x) throws SQLException {
preparedStatement.setURL(parameterIndex, x);
}
@@ -729,6 +763,7 @@
* @see java.sql.ParameterMetaData
* @since 1.4
*/
+ @Override
public ParameterMetaData getParameterMetaData() throws SQLException {
return preparedStatement.getParameterMetaData();
}
@@ -761,6 +796,7 @@
return cached;
}
+ @Override
public void close() throws SQLException {
if (!cached) {
// Stop leak tracing
@@ -800,55 +836,59 @@
}
}
+ @Override
public void closeOnCompletion() throws SQLException {
- if (DataSourceObjectBuilder.isJDBC41()) {
- if (!cached) {
- // If statement caching is not turned on, call the driver implementation
- // directly
- if (leakDetector != null) {
- _logger.log(Level.INFO, "jdbc.invalid_operation.close_on_completion");
- throw new UnsupportedOperationException("Not supported yet.");
- }
- actualCloseOnCompletion();
- } else {
- super.closeOnCompletion();
+ if (!cached) {
+ // If statement caching is not turned on, call the driver implementation
+ // directly
+ if (leakDetector != null) {
+ _logger.log(Level.INFO, "jdbc.invalid_operation.close_on_completion");
+ throw new UnsupportedOperationException("Not supported yet.");
}
+ actualCloseOnCompletion();
+ } else {
+ super.closeOnCompletion();
}
}
+ @Override
public boolean isCloseOnCompletion() throws SQLException {
- if (DataSourceObjectBuilder.isJDBC41()) {
- if (cached) {
- return getCloseOnCompletion();
- }
+ if (cached) {
+ return getCloseOnCompletion();
}
+
return super.isCloseOnCompletion();
}
+ @Override
public void setMaxFieldSize(int max) throws SQLException {
preparedStatement.setMaxFieldSize(max);
if (cached)
currentMaxFieldSize = max;
}
+ @Override
public void setMaxRows(int max) throws SQLException {
preparedStatement.setMaxRows(max);
if (cached)
currentMaxRows = max;
}
+ @Override
public void setQueryTimeout(int seconds) throws SQLException {
preparedStatement.setQueryTimeout(seconds);
if (cached)
currentQueryTimeout = seconds;
}
+ @Override
public void setFetchDirection(int direction) throws SQLException {
preparedStatement.setFetchDirection(direction);
if (cached)
currentFetchDirection = direction;
}
+ @Override
public void setFetchSize(int rows) throws SQLException {
preparedStatement.setFetchSize(rows);
if (cached)
@@ -869,13 +909,14 @@
public void incrementResultSetReferenceCount() {
// Update resultSetCount to be used in case of jdbc41 closeOnCompletion
- if (isJDBC41() && getCached()) {
+ if (getCached()) {
incrementResultSetCount();
}
}
+ @Override
public void resultSetClosed() throws SQLException {
- if (isJDBC41() && getCached()) {
+ if (getCached()) {
decrementResultSetCount();
if (getCloseOnCompletion() && getResultSetCount() == 0) {
ConnectionHolder wrappedCon = (ConnectionHolder) getConnection();
diff --git a/appserver/jdbc/jdbc-ra/jdbc-core/src/main/java/com/sun/gjc/spi/base/StatementWrapper.java b/appserver/jdbc/jdbc-ra/jdbc-core/src/main/java/com/sun/gjc/spi/base/StatementWrapper.java
index 9a6ce0d..a81f81e 100644
--- a/appserver/jdbc/jdbc-ra/jdbc-core/src/main/java/com/sun/gjc/spi/base/StatementWrapper.java
+++ b/appserver/jdbc/jdbc-ra/jdbc-core/src/main/java/com/sun/gjc/spi/base/StatementWrapper.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2022 Contributors to the Eclipse Foundation.
* Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
@@ -26,7 +27,6 @@
import java.util.logging.Level;
import java.util.logging.Logger;
-import com.sun.gjc.common.DataSourceObjectBuilder;
import com.sun.gjc.util.MethodExecutor;
import com.sun.gjc.util.StatementLeakDetector;
import com.sun.gjc.util.StatementLeakListener;
@@ -89,6 +89,7 @@
* @throws java.sql.SQLException if a database access error occurs or the given
* SQL statement produces a <code>ResultSet</code> object
*/
+ @Override
public int executeUpdate(final String sql) throws SQLException {
return jdbcStatement.executeUpdate(sql);
}
@@ -108,6 +109,7 @@
*
* @throws java.sql.SQLException if a database access error occurs
*/
+ @Override
public void close() throws SQLException {
// Stop leak tracing
if (leakDetector != null) {
@@ -129,6 +131,7 @@
* @throws java.sql.SQLException if a database access error occurs
* @see #setMaxFieldSize
*/
+ @Override
public int getMaxFieldSize() throws SQLException {
return jdbcStatement.getMaxFieldSize();
}
@@ -146,6 +149,7 @@
* condition max >= 0 is not satisfied
* @see #getMaxFieldSize
*/
+ @Override
public void setMaxFieldSize(int max) throws SQLException {
jdbcStatement.setMaxFieldSize(max);
}
@@ -161,6 +165,7 @@
* @throws java.sql.SQLException if a database access error occurs
* @see #setMaxRows
*/
+ @Override
public int getMaxRows() throws SQLException {
return jdbcStatement.getMaxRows();
}
@@ -175,6 +180,7 @@
* condition max >= 0 is not satisfied
* @see #getMaxRows
*/
+ @Override
public void setMaxRows(int max) throws SQLException {
jdbcStatement.setMaxRows(max);
}
@@ -192,6 +198,7 @@
* <code>false</code> to disable it
* @throws java.sql.SQLException if a database access error occurs
*/
+ @Override
public void setEscapeProcessing(boolean enable) throws SQLException {
jdbcStatement.setEscapeProcessing(enable);
}
@@ -206,6 +213,7 @@
* @throws java.sql.SQLException if a database access error occurs
* @see #setQueryTimeout
*/
+ @Override
public int getQueryTimeout() throws SQLException {
return jdbcStatement.getQueryTimeout();
}
@@ -221,6 +229,7 @@
* condition seconds >= 0 is not satisfied
* @see #getQueryTimeout
*/
+ @Override
public void setQueryTimeout(int seconds) throws SQLException {
jdbcStatement.setQueryTimeout(seconds);
}
@@ -232,6 +241,7 @@
*
* @throws java.sql.SQLException if a database access error occurs
*/
+ @Override
public void cancel() throws SQLException {
jdbcStatement.cancel();
}
@@ -258,6 +268,7 @@
* @throws java.sql.SQLException if a database access error occurs or this
* method is called on a closed statement
*/
+ @Override
public SQLWarning getWarnings() throws SQLException {
return jdbcStatement.getWarnings();
}
@@ -270,6 +281,7 @@
*
* @throws java.sql.SQLException if a database access error occurs
*/
+ @Override
public void clearWarnings() throws SQLException {
jdbcStatement.clearWarnings();
}
@@ -294,6 +306,7 @@
* @param name the new cursor name, which must be unique within a connection
* @throws java.sql.SQLException if a database access error occurs
*/
+ @Override
public void setCursorName(String name) throws SQLException {
jdbcStatement.setCursorName(name);
}
@@ -318,6 +331,7 @@
* @see #getUpdateCount
* @see #getMoreResults
*/
+ @Override
public boolean execute(final String sql) throws SQLException {
return jdbcStatement.execute(sql);
}
@@ -332,6 +346,7 @@
* @throws java.sql.SQLException if a database access error occurs
* @see #execute
*/
+ @Override
public int getUpdateCount() throws SQLException {
return jdbcStatement.getUpdateCount();
}
@@ -356,6 +371,7 @@
* @throws java.sql.SQLException if a database access error occurs
* @see #execute
*/
+ @Override
public boolean getMoreResults() throws SQLException {
return jdbcStatement.getMoreResults();
}
@@ -376,6 +392,7 @@
* @see #getFetchDirection
* @since 1.2
*/
+ @Override
public void setFetchDirection(int direction) throws SQLException {
jdbcStatement.setFetchDirection(direction);
}
@@ -393,6 +410,7 @@
* @see #setFetchDirection
* @since 1.2
*/
+ @Override
public int getFetchDirection() throws SQLException {
return jdbcStatement.getFetchDirection();
}
@@ -410,6 +428,7 @@
* @see #getFetchSize
* @since 1.2
*/
+ @Override
public void setFetchSize(int rows) throws SQLException {
jdbcStatement.setFetchSize(rows);
}
@@ -427,6 +446,7 @@
* @see #setFetchSize
* @since 1.2
*/
+ @Override
public int getFetchSize() throws SQLException {
return jdbcStatement.getFetchSize();
}
@@ -440,6 +460,7 @@
* @throws java.sql.SQLException if a database access error occurs
* @since 1.2
*/
+ @Override
public int getResultSetConcurrency() throws SQLException {
return jdbcStatement.getResultSetConcurrency();
}
@@ -454,6 +475,7 @@
* @throws java.sql.SQLException if a database access error occurs
* @since 1.2
*/
+ @Override
public int getResultSetType() throws SQLException {
return jdbcStatement.getResultSetType();
}
@@ -472,6 +494,7 @@
* @see #executeBatch
* @since 1.2
*/
+ @Override
public void addBatch(String sql) throws SQLException {
jdbcStatement.addBatch(sql);
}
@@ -486,6 +509,7 @@
* @see #addBatch
* @since 1.2
*/
+ @Override
public void clearBatch() throws SQLException {
jdbcStatement.clearBatch();
}
@@ -535,6 +559,7 @@
* to execute properly or attempts to return a result set.
* @since 1.3
*/
+ @Override
public int[] executeBatch() throws SQLException {
return jdbcStatement.executeBatch();
}
@@ -547,6 +572,7 @@
* @throws java.sql.SQLException if a database access error occurs
* @since 1.2
*/
+ @Override
public Connection getConnection() throws SQLException {
return connection;
}
@@ -592,6 +618,7 @@
* @see #execute
* @since 1.4
*/
+ @Override
public boolean getMoreResults(int current) throws SQLException {
return jdbcStatement.getMoreResults(current);
}
@@ -615,6 +642,7 @@
* is not one of those allowed
* @since 1.4
*/
+ @Override
public int executeUpdate(final String sql, int autoGeneratedKeys) throws SQLException {
return jdbcStatement.executeUpdate(sql, autoGeneratedKeys);
}
@@ -638,6 +666,7 @@
* valid column indexes
* @since 1.4
*/
+ @Override
public int executeUpdate(final String sql, int columnIndexes[]) throws SQLException {
return jdbcStatement.executeUpdate(sql, columnIndexes);
}
@@ -660,6 +689,7 @@
* valid column names
* @since 1.4
*/
+ @Override
public int executeUpdate(final String sql, String columnNames[]) throws SQLException {
return jdbcStatement.executeUpdate(sql, columnNames);
}
@@ -698,6 +728,7 @@
* @see #getGeneratedKeys
* @since 1.4
*/
+ @Override
public boolean execute(final String sql, int autoGeneratedKeys) throws SQLException {
return jdbcStatement.execute(sql, autoGeneratedKeys);
}
@@ -734,6 +765,7 @@
* @see #getMoreResults
* @since 1.4
*/
+ @Override
public boolean execute(final String sql, int columnIndexes[]) throws SQLException {
return jdbcStatement.execute(sql, columnIndexes);
}
@@ -772,6 +804,7 @@
* @see #getGeneratedKeys
* @since 1.4
*/
+ @Override
public boolean execute(final String sql, String columnNames[]) throws SQLException {
return jdbcStatement.execute(sql, columnNames);
}
@@ -785,10 +818,12 @@
* @throws java.sql.SQLException if a database access error occurs
* @since 1.4
*/
+ @Override
public int getResultSetHoldability() throws SQLException {
return jdbcStatement.getResultSetHoldability();
}
+ @Override
public void reclaimStatement() throws SQLException {
markForReclaim(true);
close();
@@ -802,16 +837,15 @@
return markedForReclaim;
}
+ @Override
public void closeOnCompletion() throws SQLException {
if (leakDetector != null) {
_logger.log(Level.INFO, "jdbc.invalid_operation.close_on_completion");
throw new UnsupportedOperationException("Not supported yet.");
}
- if (DataSourceObjectBuilder.isJDBC41()) {
- closeOnCompletion = true;
- return;
- }
- throw new UnsupportedOperationException("Operation not supported in this runtime.");
+
+ closeOnCompletion = true;
+ return;
}
public void actualCloseOnCompletion() throws SQLException {
@@ -821,19 +855,18 @@
_logger.log(Level.SEVERE, "jdbc.ex_stmt_wrapper", ex);
throw new SQLException(ex);
}
+
return;
}
+ @Override
public boolean isCloseOnCompletion() throws SQLException {
- if (DataSourceObjectBuilder.isJDBC41()) {
- try {
- return (Boolean) executor.invokeMethod(jdbcStatement, "isCloseOnCompletion", null);
- } catch (ResourceException ex) {
- _logger.log(Level.SEVERE, "jdbc.ex_stmt_wrapper", ex);
- throw new SQLException(ex);
- }
+ try {
+ return (Boolean) executor.invokeMethod(jdbcStatement, "isCloseOnCompletion", null);
+ } catch (ResourceException ex) {
+ _logger.log(Level.SEVERE, "jdbc.ex_stmt_wrapper", ex);
+ throw new SQLException(ex);
}
- throw new UnsupportedOperationException("Operation not supported in this runtime.");
}
public boolean getCloseOnCompletion() {
diff --git a/appserver/jdbc/jdbc-ra/jdbc-core/src/main/java/com/sun/gjc/util/MethodExecutor.java b/appserver/jdbc/jdbc-ra/jdbc-core/src/main/java/com/sun/gjc/util/MethodExecutor.java
index a9c2836..c7d7951 100644
--- a/appserver/jdbc/jdbc-ra/jdbc-core/src/main/java/com/sun/gjc/util/MethodExecutor.java
+++ b/appserver/jdbc/jdbc-ra/jdbc-core/src/main/java/com/sun/gjc/util/MethodExecutor.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2022 Contributors to the Eclipse Foundation.
* Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
@@ -28,8 +29,8 @@
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.Enumeration;
+import java.util.List;
import java.util.Properties;
-import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -68,13 +69,14 @@
return;
}
- Class[] parameters = method.getParameterTypes();
+ Class<?>[] parameters = method.getParameterTypes();
if (parameters.length == 1) {
Object[] values = new Object[1];
values[0] = convertType(parameters[0], value);
final ResourceException[] exception = new ResourceException[1];
- AccessController.doPrivileged(new PrivilegedAction() {
+ AccessController.doPrivileged(new PrivilegedAction<>() {
+ @Override
public Object run() {
try {
method.setAccessible(true);
@@ -108,22 +110,25 @@
* @throws <code>ResourceException</code>, in case of the mismatch of parameter
* values or a security violation.
*/
- public void runMethod(Method method, Object obj, Vector values) throws ResourceException {
- Class[] parameters = method.getParameterTypes();
+ public void runMethod(Method method, Object obj, List<String> values) throws ResourceException {
+ Class<?>[] parameters = method.getParameterTypes();
if (values.size() != parameters.length) {
return;
}
+
Object[] actualValues = new Object[parameters.length];
for (int i = 0; i < parameters.length; i++) {
- String val = (String) values.get(i);
+ String val = values.get(i);
if (val.trim().equals("NULL")) {
actualValues[i] = null;
} else {
actualValues[i] = convertType(parameters[i], val);
}
}
+
final ResourceException[] exception = new ResourceException[1];
- AccessController.doPrivileged(new PrivilegedAction() {
+ AccessController.doPrivileged(new PrivilegedAction<>() {
+ @Override
public Object run() {
try {
method.setAccessible(true);
@@ -142,6 +147,7 @@
return null;
}
});
+
if (exception[0] != null) {
throw exception[0];
}
@@ -156,7 +162,7 @@
* @throws <code>ResourceException</code>, in case of the mismatch of parameter
* values or a security violation.
*/
- private Object convertType(Class type, String parameter) throws ResourceException {
+ private Object convertType(Class<?> type, String parameter) throws ResourceException {
try {
String typeName = type.getName();
if (typeName.equals("java.lang.String") || typeName.equals("java.lang.Object")) {
diff --git a/appserver/jdbc/jdbc-ra/jdbc40/src/main/java/com/sun/gjc/spi/jdbc40/CallableStatementWrapper40.java b/appserver/jdbc/jdbc-ra/jdbc40/src/main/java/com/sun/gjc/spi/jdbc40/CallableStatementWrapper40.java
index 65176ec..19b7a4f 100644
--- a/appserver/jdbc/jdbc-ra/jdbc40/src/main/java/com/sun/gjc/spi/jdbc40/CallableStatementWrapper40.java
+++ b/appserver/jdbc/jdbc-ra/jdbc40/src/main/java/com/sun/gjc/spi/jdbc40/CallableStatementWrapper40.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2022 Contributors to the Eclipse Foundation.
* Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
@@ -16,7 +17,6 @@
package com.sun.gjc.spi.jdbc40;
-import static com.sun.gjc.common.DataSourceObjectBuilder.isJDBC41;
import static java.util.logging.Level.SEVERE;
import java.io.InputStream;
@@ -1516,10 +1516,6 @@
@Override
@SuppressWarnings("unchecked")
public <T> T getObject(int parameterIndex, Class<T> type) throws SQLException {
- if (!isJDBC41()) {
- throw new UnsupportedOperationException("Operation not supported in this runtime.");
- }
-
Class<?>[] valueTypes = new Class<?>[] { Integer.TYPE, Class.class };
try {
return (T) executor.invokeMethod(jdbcStatement, "getObject", valueTypes, parameterIndex, type);
@@ -1532,10 +1528,6 @@
@Override
@SuppressWarnings("unchecked")
public <T> T getObject(String parameterName, Class<T> type) throws SQLException {
- if (!isJDBC41()) {
- throw new UnsupportedOperationException("Operation not supported in this runtime.");
- }
-
Class<?>[] valueTypes = new Class<?>[] { String.class, Class.class };
try {
return (T) executor.invokeMethod(jdbcStatement, "getObject", valueTypes, parameterName, type);
diff --git a/appserver/jdbc/jdbc-ra/jdbc40/src/main/java/com/sun/gjc/spi/jdbc40/ConnectionHolder40.java b/appserver/jdbc/jdbc-ra/jdbc40/src/main/java/com/sun/gjc/spi/jdbc40/ConnectionHolder40.java
index 6ceaa78..d54e222 100644
--- a/appserver/jdbc/jdbc-ra/jdbc40/src/main/java/com/sun/gjc/spi/jdbc40/ConnectionHolder40.java
+++ b/appserver/jdbc/jdbc-ra/jdbc40/src/main/java/com/sun/gjc/spi/jdbc40/ConnectionHolder40.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2022 Contributors to the Eclipse Foundation.
* Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
@@ -16,7 +17,6 @@
package com.sun.gjc.spi.jdbc40;
-import static com.sun.gjc.common.DataSourceObjectBuilder.isJDBC41;
import static java.util.logging.Level.FINE;
import static java.util.logging.Level.FINEST;
import static java.util.logging.Level.INFO;
@@ -86,7 +86,6 @@
defaultClientInfo = getClientInfo();
}
} catch (Throwable e) {
- _logger.log(INFO, "jdbc.unable_to_get_client_info", e.getMessage());
_logger.log(FINEST, "jdbc.unable_to_get_client_info", e);
}
}
@@ -584,7 +583,6 @@
}
}
} catch (Throwable e) {
- _logger.log(INFO, "jdbc.unable_to_set_client_info", e.getMessage());
_logger.log(FINEST, "jdbc.unable_to_set_client_info", e);
}
}
@@ -594,10 +592,6 @@
@Override
public void setSchema(String schema) throws SQLException {
- if (!isJDBC41()) {
- throw new UnsupportedOperationException("Operation not supported in this runtime.");
- }
-
checkValidity();
Class<?>[] valueTypes = new Class<?>[] { String.class };
@@ -614,10 +608,6 @@
@Override
public String getSchema() throws SQLException {
- if (!isJDBC41()) {
- throw new UnsupportedOperationException("Operation not supported in this runtime.");
- }
-
checkValidity();
try {
@@ -630,10 +620,6 @@
@Override
public void setNetworkTimeout(Executor executorObj, int milliseconds) throws SQLException {
- if (!isJDBC41()) {
- throw new UnsupportedOperationException("Operation not supported in this runtime.");
- }
-
checkValidity();
Class<?>[] valueTypes = new Class<?>[] { Executor.class, Integer.TYPE };
@@ -648,10 +634,6 @@
@Override
public int getNetworkTimeout() throws SQLException {
- if (!isJDBC41()) {
- throw new UnsupportedOperationException("Operation not supported in this runtime.");
- }
-
checkValidity();
try {
@@ -673,10 +655,6 @@
*/
@Override
public void abort(Executor executor) throws SQLException {
- if (!isJDBC41()) {
- throw new UnsupportedOperationException("Operation not supported in this runtime.");
- }
-
getManagedConnection().markForRemoval(true);
getManagedConnection().setAborted(true);
if (!getManagedConnection().isTransactionInProgress()) {
diff --git a/appserver/jdbc/jdbc-ra/jdbc40/src/main/java/com/sun/gjc/spi/jdbc40/DataSource40.java b/appserver/jdbc/jdbc-ra/jdbc40/src/main/java/com/sun/gjc/spi/jdbc40/DataSource40.java
index 3f5e3f9..7a43fb9 100644
--- a/appserver/jdbc/jdbc-ra/jdbc40/src/main/java/com/sun/gjc/spi/jdbc40/DataSource40.java
+++ b/appserver/jdbc/jdbc-ra/jdbc40/src/main/java/com/sun/gjc/spi/jdbc40/DataSource40.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2022 Contributors to the Eclipse Foundation.
* Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
@@ -16,7 +17,6 @@
package com.sun.gjc.spi.jdbc40;
-import static com.sun.gjc.common.DataSourceObjectBuilder.isJDBC41;
import static java.util.logging.Level.SEVERE;
import static java.util.logging.Level.WARNING;
@@ -136,10 +136,6 @@
@Override
public Logger getParentLogger() throws SQLFeatureNotSupportedException {
- if (!isJDBC41()) {
- throw new UnsupportedOperationException("Operation not supported in this runtime.");
- }
-
try {
return (Logger) executor.invokeMethod(managedConnectionFactoryImpl.getDataSource().getClass(), "getParentLogger", null);
} catch (ResourceException ex) {
diff --git a/appserver/jdbc/jdbc-ra/jdbc40/src/main/java/com/sun/gjc/spi/jdbc40/DatabaseMetaDataWrapper40.java b/appserver/jdbc/jdbc-ra/jdbc40/src/main/java/com/sun/gjc/spi/jdbc40/DatabaseMetaDataWrapper40.java
index 5ac0227..cc33230 100644
--- a/appserver/jdbc/jdbc-ra/jdbc40/src/main/java/com/sun/gjc/spi/jdbc40/DatabaseMetaDataWrapper40.java
+++ b/appserver/jdbc/jdbc-ra/jdbc40/src/main/java/com/sun/gjc/spi/jdbc40/DatabaseMetaDataWrapper40.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2022 Contributors to the Eclipse Foundation.
* Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
@@ -23,7 +24,6 @@
import java.sql.SQLException;
import java.util.logging.Level;
-import com.sun.gjc.common.DataSourceObjectBuilder;
import com.sun.gjc.spi.base.DatabaseMetaDataWrapper;
import jakarta.resource.ResourceException;
@@ -373,31 +373,24 @@
}
@Override
- public ResultSet getPseudoColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern)
- throws SQLException {
- if (DataSourceObjectBuilder.isJDBC41()) {
- Class<?>[] valueTypes = new Class<?>[] { String.class, String.class, String.class, String.class };
- try {
- return (ResultSet) getMethodExecutor().invokeMethod(databaseMetaData, "getPseudoColumns", valueTypes, catalog,
- schemaPattern, tableNamePattern, columnNamePattern);
- } catch (ResourceException ex) {
- _logger.log(Level.SEVERE, "jdbc.ex_dmd_wrapper", ex);
- throw new SQLException(ex);
- }
+ public ResultSet getPseudoColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException {
+ Class<?>[] valueTypes = new Class<?>[] { String.class, String.class, String.class, String.class };
+ try {
+ return (ResultSet) getMethodExecutor().invokeMethod(databaseMetaData, "getPseudoColumns", valueTypes, catalog,
+ schemaPattern, tableNamePattern, columnNamePattern);
+ } catch (ResourceException ex) {
+ _logger.log(Level.SEVERE, "jdbc.ex_dmd_wrapper", ex);
+ throw new SQLException(ex);
}
- throw new UnsupportedOperationException("Operation not supported in this runtime.");
}
@Override
public boolean generatedKeyAlwaysReturned() throws SQLException {
- if (DataSourceObjectBuilder.isJDBC41()) {
- try {
- return (Boolean) getMethodExecutor().invokeMethod(databaseMetaData, "generatedKeyAlwaysReturned", null);
- } catch (ResourceException ex) {
- _logger.log(Level.SEVERE, "jdbc.ex_dmd_wrapper", ex);
- throw new SQLException(ex);
- }
+ try {
+ return (Boolean) getMethodExecutor().invokeMethod(databaseMetaData, "generatedKeyAlwaysReturned", null);
+ } catch (ResourceException ex) {
+ _logger.log(Level.SEVERE, "jdbc.ex_dmd_wrapper", ex);
+ throw new SQLException(ex);
}
- throw new UnsupportedOperationException("Operation not supported in this runtime.");
}
}
diff --git a/appserver/jdbc/jdbc-ra/jdbc40/src/main/java/com/sun/gjc/spi/jdbc40/ResultSetWrapper40.java b/appserver/jdbc/jdbc-ra/jdbc40/src/main/java/com/sun/gjc/spi/jdbc40/ResultSetWrapper40.java
index c54f7ed..a42af08 100644
--- a/appserver/jdbc/jdbc-ra/jdbc40/src/main/java/com/sun/gjc/spi/jdbc40/ResultSetWrapper40.java
+++ b/appserver/jdbc/jdbc-ra/jdbc40/src/main/java/com/sun/gjc/spi/jdbc40/ResultSetWrapper40.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2022 Contributors to the Eclipse Foundation.
* Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
@@ -16,7 +17,6 @@
package com.sun.gjc.spi.jdbc40;
-import static com.sun.gjc.common.DataSourceObjectBuilder.isJDBC41;
import static java.util.logging.Level.SEVERE;
import java.io.InputStream;
@@ -96,10 +96,6 @@
@SuppressWarnings("unchecked")
@Override
public <T> T getObject(int columnIndex, Class<T> type) throws SQLException {
- if (!isJDBC41()) {
- throw new UnsupportedOperationException("Operation not supported in this runtime.");
- }
-
Class<?>[] valueTypes = new Class<?>[] { Integer.TYPE, Class.class };
try {
return (T) getMethodExecutor().invokeMethod(resultSet, "getObject", valueTypes, columnIndex, type);
@@ -112,10 +108,6 @@
@SuppressWarnings("unchecked")
@Override
public <T> T getObject(String columnLabel, Class<T> type) throws SQLException {
- if (!isJDBC41()) {
- throw new UnsupportedOperationException("Operation not supported in this runtime.");
- }
-
Class<?>[] valueTypes = new Class<?>[] { String.class, Class.class };
try {
return (T) getMethodExecutor().invokeMethod(resultSet, "getObject", valueTypes, columnLabel, type);