From a1bba88cba9cecf4bc56eee0c5b0df25a90c547c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20Ferreira?= Date: Fri, 7 Oct 2016 15:53:40 +0100 Subject: [PATCH] Fix styles in preto jdbc --- .../presto/jdbc/PrestoPreparedStatement.java | 23 ++++++++++++------- .../com/facebook/presto/jdbc/TestDriver.java | 4 +--- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoPreparedStatement.java b/presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoPreparedStatement.java index 63c9fb8023df..2bf3aba2d48f 100644 --- a/presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoPreparedStatement.java +++ b/presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoPreparedStatement.java @@ -204,20 +204,27 @@ public void setObject(int parameterIndex, Object x, int targetSqlType) public void setObject(int parameterIndex, Object x) throws SQLException { - if (x instanceof String) + if (x instanceof String) { sql = sql.replaceFirst("([?])", "'" + x.toString() + "'"); - else if (x instanceof BigDecimal) - setBigDecimal(parameterIndex, (BigDecimal)x); - else if (x instanceof Short) + } + else if (x instanceof BigDecimal) { + setBigDecimal(parameterIndex, (BigDecimal) x); + } + else if (x instanceof Short) { setShort(parameterIndex, (Short) x); - else if (x instanceof Integer) + } + else if (x instanceof Integer) { setInt(parameterIndex, (Integer) x); - else if (x instanceof Long) + } + else if (x instanceof Long) { setLong(parameterIndex, (Long) x); - else if (x instanceof Float) + } + else if (x instanceof Float) { setFloat(parameterIndex, (Float) x); - else if (x instanceof Double) + } + else if (x instanceof Double) { setDouble(parameterIndex, (Double) x); + } } @Override diff --git a/presto-jdbc/src/test/java/com/facebook/presto/jdbc/TestDriver.java b/presto-jdbc/src/test/java/com/facebook/presto/jdbc/TestDriver.java index 301c998fe1f9..2e4ee09e2366 100644 --- a/presto-jdbc/src/test/java/com/facebook/presto/jdbc/TestDriver.java +++ b/presto-jdbc/src/test/java/com/facebook/presto/jdbc/TestDriver.java @@ -39,7 +39,6 @@ import com.google.common.collect.ImmutableSet; import io.airlift.log.Logging; import io.airlift.units.Duration; -import java.sql.PreparedStatement; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; import org.testng.annotations.AfterClass; @@ -50,6 +49,7 @@ import java.sql.Connection; import java.sql.Date; import java.sql.DriverManager; +import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; @@ -1049,7 +1049,6 @@ public void testExecutePreparedWithQuery() { try (Connection connection = createConnection()) { try (PreparedStatement statement = connection.prepareStatement("SELECT ? as param1StringValue, ? as param2NumberValue")) { - statement.clearParameters(); statement.setObject(1, "foo"); statement.setObject(2, 123); @@ -1089,7 +1088,6 @@ public void testExecutePreparedWithQueryWithNullValues() { try (Connection connection = createConnection()) { try (PreparedStatement statement = connection.prepareStatement("SELECT ? as param1StringValue")) { - statement.clearParameters(); ResultSet rs = statement.executeQuery();