Skip to content

Commit

Permalink
Fix styles in preto jdbc
Browse files Browse the repository at this point in the history
  • Loading branch information
Flávio Ferreira committed Oct 10, 2016
1 parent f57af51 commit a1bba88
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit a1bba88

Please sign in to comment.