Skip to content
Permalink
Browse files

Merge 303ea85 into c30556c

  • Loading branch information...
myowaithant9 committed Jul 22, 2019
2 parents c30556c + 303ea85 commit 6e3e133302d7be3df9a6e433dd253999bd045a7c
@@ -39,6 +39,8 @@
import org.postgresql.util.PSQLState;

import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.sql.Array;
import java.sql.Blob;
import java.sql.CallableStatement;
@@ -549,6 +551,15 @@ public Object getObject(String type, String value, byte[] byteValue) throws SQLE
}
}

if (type.equals("inet")) {
try {
return InetAddress.getByName(value);
} catch (UnknownHostException e) {
throw new PSQLException(GT.tr("IP address {0} of a host could not be determined", value),
PSQLState.CONNECTION_FAILURE, e);
}
}

PGobject obj = null;

if (LOGGER.isLoggable(Level.FINEST)) {
@@ -36,7 +36,6 @@
import java.math.BigDecimal;
import java.math.BigInteger;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.sql.Array;
import java.sql.Blob;
import java.sql.Clob;
@@ -219,6 +218,10 @@ protected Object internalGetObject(int columnIndex, Field field) throws SQLExcep
return getString(columnIndex);
}

if (type.equals("inet")) {
return getInetAddress(getPGType(columnIndex), getString(columnIndex));
}

if (type.equals("uuid")) {
if (isBinary(columnIndex)) {
return getUUID(thisRow[columnIndex - 1]);
@@ -3056,6 +3059,16 @@ protected Object getUUID(byte[] data) throws SQLException {
return new UUID(ByteConverter.int8(data, 0), ByteConverter.int8(data, 8));
}

protected Object getInetAddress(String type, String data) throws SQLException {
InetAddress inet;
try {
inet = (InetAddress) connection.getObject(type, data, null);
} catch (IllegalArgumentException iae) {
throw new PSQLException(GT.tr("Invalid Inet data."), PSQLState.INVALID_PARAMETER_VALUE, iae);
}
return inet;
}

private class PrimaryKey {
int index; // where in the result set is this primaryKey
String name; // what is the columnName of this primary Key
@@ -3310,11 +3323,7 @@ public void updateArray(String columnName, Array x) throws SQLException {
if (addressString == null) {
return null;
}
try {
return type.cast(InetAddress.getByName(((PGobject) addressString).getValue()));
} catch (UnknownHostException e) {
throw new SQLException("could not create inet address from string '" + addressString + "'");
}
return type.cast(getObject(columnIndex));
// JSR-310 support
//#if mvn.project.property.postgresql.jdbc.spec >= "JDBC4.2"
} else if (type == LocalDate.class) {

0 comments on commit 6e3e133

Please sign in to comment.
You can’t perform that action at this time.