Skip to content

Commit

Permalink
Merge pull request #499 from Microsoft/revert-487-removal_of_deprecat…
Browse files Browse the repository at this point in the history
…ed_APIs

Revert "Removing deprecated APIs in java 9"
  • Loading branch information
AfsanehR-zz authored Sep 22, 2017
2 parents 44a1cfe + 0047c3b commit 24dfd49
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 24 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/microsoft/sqlserver/jdbc/DDC.java
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ static final Object convertFloatToObject(float floatVal,
return new BigDecimal(Float.toString(floatVal));
case FLOAT:
case DOUBLE:
return (Float.valueOf(floatVal)).doubleValue();
return (new Float(floatVal)).doubleValue();
case BINARY:
return convertIntToBytes(Float.floatToRawIntBits(floatVal), 4);
default:
Expand Down Expand Up @@ -275,7 +275,7 @@ static final Object convertDoubleToObject(double doubleVal,
case DOUBLE:
return doubleVal;
case REAL:
return (Double.valueOf(doubleVal)).floatValue();
return (new Double(doubleVal)).floatValue();
case INTEGER:
return (int) doubleVal;
case SMALLINT: // small and tinyint returned as short
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private void setupInfo(SQLServerConnection con) throws SQLServerException {
instancePort = con.getInstancePort(failoverPartner, instanceValue);

try {
portNumber = Integer.parseInt(instancePort);
portNumber = new Integer(instancePort);
}
catch (NumberFormatException e) {
// Should not get here as the server should give a proper port number anyway.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.time.OffsetTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
Expand Down Expand Up @@ -574,7 +575,7 @@ public Object[] getRowData() throws SQLServerException {
case Types.BIGINT: {
BigDecimal bd = new BigDecimal(data[pair.getKey() - 1].trim());
try {
dataRow[pair.getKey() - 1] = bd.setScale(0, RoundingMode.DOWN).longValueExact();
dataRow[pair.getKey() - 1] = bd.setScale(0, BigDecimal.ROUND_DOWN).longValueExact();
} catch (ArithmeticException ex) {
String value = "'" + data[pair.getKey() - 1] + "'";
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_errorConvertingValue"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1418,7 +1418,7 @@ Connection connectInternal(Properties propsIn,
sPropKey = SQLServerDriverIntProperty.STATEMENT_POOLING_CACHE_SIZE.toString();
if (activeConnectionProperties.getProperty(sPropKey) != null && activeConnectionProperties.getProperty(sPropKey).length() > 0) {
try {
int n = Integer.parseInt(activeConnectionProperties.getProperty(sPropKey));
int n = new Integer(activeConnectionProperties.getProperty(sPropKey));
this.setStatementPoolingCacheSize(n);
}
catch (NumberFormatException e) {
Expand Down Expand Up @@ -1555,7 +1555,7 @@ Connection connectInternal(Properties propsIn,
try {
String strPort = activeConnectionProperties.getProperty(sPropKey);
if (null != strPort) {
nPort = Integer.parseInt(strPort);
nPort = new Integer(strPort);

if ((nPort < 0) || (nPort > 65535)) {
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_invalidPortNumber"));
Expand Down Expand Up @@ -1635,7 +1635,7 @@ else if (0 == requestedPacketSize)
nLockTimeout = defaultLockTimeOut; // Wait forever
if (activeConnectionProperties.getProperty(sPropKey) != null && activeConnectionProperties.getProperty(sPropKey).length() > 0) {
try {
int n = Integer.parseInt(activeConnectionProperties.getProperty(sPropKey));
int n = new Integer(activeConnectionProperties.getProperty(sPropKey));
if (n >= defaultLockTimeOut)
nLockTimeout = n;
else {
Expand All @@ -1656,7 +1656,7 @@ else if (0 == requestedPacketSize)
queryTimeoutSeconds = defaultQueryTimeout; // Wait forever
if (activeConnectionProperties.getProperty(sPropKey) != null && activeConnectionProperties.getProperty(sPropKey).length() > 0) {
try {
int n = Integer.parseInt(activeConnectionProperties.getProperty(sPropKey));
int n = new Integer(activeConnectionProperties.getProperty(sPropKey));
if (n >= defaultQueryTimeout) {
queryTimeoutSeconds = n;
}
Expand All @@ -1678,7 +1678,7 @@ else if (0 == requestedPacketSize)
socketTimeoutMilliseconds = defaultSocketTimeout; // Wait forever
if (activeConnectionProperties.getProperty(sPropKey) != null && activeConnectionProperties.getProperty(sPropKey).length() > 0) {
try {
int n = Integer.parseInt(activeConnectionProperties.getProperty(sPropKey));
int n = new Integer(activeConnectionProperties.getProperty(sPropKey));
if (n >= defaultSocketTimeout) {
socketTimeoutMilliseconds = n;
}
Expand All @@ -1698,7 +1698,7 @@ else if (0 == requestedPacketSize)
sPropKey = SQLServerDriverIntProperty.SERVER_PREPARED_STATEMENT_DISCARD_THRESHOLD.toString();
if (activeConnectionProperties.getProperty(sPropKey) != null && activeConnectionProperties.getProperty(sPropKey).length() > 0) {
try {
int n = Integer.parseInt(activeConnectionProperties.getProperty(sPropKey));
int n = new Integer(activeConnectionProperties.getProperty(sPropKey));
setServerPreparedStatementDiscardThreshold(n);
}
catch (NumberFormatException e) {
Expand Down Expand Up @@ -2158,7 +2158,7 @@ ServerPortPlaceHolder primaryPermissionCheck(String primary,
connectionlogger.fine(toString() + " SQL Server port returned by SQL Browser: " + instancePort);
try {
if (null != instancePort) {
primaryPortNumber = Integer.parseInt(instancePort);
primaryPortNumber = new Integer(instancePort);

if ((primaryPortNumber < 0) || (primaryPortNumber > 65535)) {
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_invalidPortNumber"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ private void setIntProperty(Properties props,
int propValue) {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
loggerExternal.entering(getClassNameLogging(), "set" + propKey, propValue);
props.setProperty(propKey, Integer.valueOf(propValue).toString());
props.setProperty(propKey, new Integer(propValue).toString());
loggerExternal.exiting(getClassNameLogging(), "set" + propKey);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

package com.microsoft.sqlserver.jdbc;

import java.lang.reflect.InvocationTargetException;
import java.util.Hashtable;

import javax.naming.Context;
Expand Down Expand Up @@ -36,7 +35,7 @@ public SQLServerDataSourceObjectFactory() {
public Object getObjectInstance(Object ref,
Name name,
Context c,
Hashtable<?, ?> h) throws SQLServerException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
Hashtable<?, ?> h) throws SQLServerException {
// Create a new instance of a DataSource class from the given reference.
try {
javax.naming.Reference r = (javax.naming.Reference) ref;
Expand All @@ -60,7 +59,7 @@ public Object getObjectInstance(Object ref,

// Create class instance and initialize using reference.
Class<?> dataSourceClass = Class.forName(className);
Object dataSourceClassInstance = dataSourceClass.getDeclaredConstructor().newInstance();
Object dataSourceClassInstance = dataSourceClass.newInstance();

// If this class we created does not cast to SQLServerDataSource, then caller
// passed in the wrong reference to our factory.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ private Properties parseAndMergeProperties(String Url,
// put the user properties into the connect properties
int nTimeout = DriverManager.getLoginTimeout();
if (nTimeout > 0) {
connectProperties.put(SQLServerDriverIntProperty.LOGIN_TIMEOUT.toString(), Integer.valueOf(nTimeout).toString());
connectProperties.put(SQLServerDriverIntProperty.LOGIN_TIMEOUT.toString(), new Integer(nTimeout).toString());
}

// Merge connectProperties (from URL) and supplied properties from user.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamException;
Expand All @@ -50,6 +48,7 @@
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;

/**
* SQLServerSQLXML represents an XML object and implements a java.sql.SQLXML.
Expand Down Expand Up @@ -406,14 +405,12 @@ private DOMSource getDOMSource() throws SQLException {
private SAXSource getSAXSource() throws SQLException {
try {
InputSource src = new InputSource(contents);
SAXParserFactory factory=SAXParserFactory.newInstance();
SAXParser parser=factory.newSAXParser();
XMLReader reader = parser.getXMLReader();
XMLReader reader = XMLReaderFactory.createXMLReader();
SAXSource saxSource = new SAXSource(reader, src);
return saxSource;

}
catch (SAXException | ParserConfigurationException e) {
catch (SAXException e) {
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_failedToParseXML"));
Object[] msgArgs = {e.toString()};
SQLServerException.makeFromDriverError(con, null, form.format(msgArgs), null, true);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/microsoft/sqlserver/jdbc/SqlVariant.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ static sqlVariantProbBytes valueOf(int intValue) {

if (!(0 <= intValue && intValue < valuesTypes.length) || null == (tdsType = valuesTypes[intValue])) {
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_unknownSSType"));
Object[] msgArgs = {Integer.valueOf(intValue)};
Object[] msgArgs = {new Integer(intValue)};
throw new IllegalArgumentException(form.format(msgArgs));
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/microsoft/sqlserver/jdbc/dtv.java
Original file line number Diff line number Diff line change
Expand Up @@ -2208,7 +2208,7 @@ void execute(DTV dtv,
if (null != bigDecimalValue) {
Integer inScale = dtv.getScale();
if (null != inScale && inScale != bigDecimalValue.scale())
bigDecimalValue = bigDecimalValue.setScale(inScale, RoundingMode.DOWN);
bigDecimalValue = bigDecimalValue.setScale(inScale, BigDecimal.ROUND_DOWN);
}

dtv.setValue(bigDecimalValue, JavaType.BIGDECIMAL);
Expand Down

0 comments on commit 24dfd49

Please sign in to comment.