Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions java/jdbc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,6 @@

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5</version>
<configuration>
<source>7</source>
<target>7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
Expand Down
28 changes: 8 additions & 20 deletions java/jdbc/src/main/java/io/vitess/jdbc/VitessConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,11 @@
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.Executor;
import java.util.logging.Logger;

import io.vitess.client.Context;
import io.vitess.client.VTGateConnection;
import io.vitess.client.VTSession;
import io.vitess.proto.Query;
import io.vitess.proto.Vtgate;
import io.vitess.util.CommonUtils;
import io.vitess.util.Constants;
import io.vitess.util.MysqlDefs;
Expand All @@ -58,7 +56,6 @@
public class VitessConnection extends ConnectionProperties implements Connection {

/* Get actual class name to be printed on */
private static Logger logger = Logger.getLogger(VitessConnection.class.getName());
private static DatabaseMetaData databaseMetaData = null;

/**
Expand Down Expand Up @@ -223,9 +220,8 @@ public void close() throws SQLException {
* Return Connection state
*
* @return DatabaseMetadata Object
* @throws SQLException
*/
public boolean isClosed() throws SQLException {
public boolean isClosed() {
return this.closed;
}

Expand Down Expand Up @@ -486,19 +482,17 @@ public void setClientInfo(String name, String value) throws SQLClientInfoExcepti
*
* @param name - Property Name
* @return Property Value
* @throws SQLException
*/
public String getClientInfo(String name) throws SQLException {
public String getClientInfo(String name) {
return null;
}

/**
* TODO: For Implementation Possibility
*
* @return - Property Object
* @throws SQLException
*/
public Properties getClientInfo() throws SQLException {
public Properties getClientInfo() {
return null;
}

Expand Down Expand Up @@ -818,11 +812,11 @@ private String initializeDBProperties() throws SQLException {

if (metadataNullOrClosed()) {
String versionValue;
ResultSet resultSet = null;
VitessStatement vitessStatement = new VitessStatement(this);
try {
resultSet = vitessStatement.executeQuery(
"SHOW VARIABLES WHERE VARIABLE_NAME IN (\'tx_isolation\',\'INNODB_VERSION\', \'lower_case_table_names\')");

try(VitessStatement vitessStatement = new VitessStatement(this);
ResultSet resultSet = vitessStatement.executeQuery(
"SHOW VARIABLES WHERE VARIABLE_NAME IN (\'tx_isolation\',\'INNODB_VERSION\', \'lower_case_table_names\')")
) {
while (resultSet.next()) {
dbVariables.put(resultSet.getString(1), resultSet.getString(2));
}
Expand Down Expand Up @@ -855,13 +849,7 @@ private String initializeDBProperties() throws SQLException {
}
this.dbProperties =
new DBProperties(productVersion, majorVersion, minorVersion, isolationLevel, lowerCaseTables);
} finally {
if (null != resultSet) {
resultSet.close();
}
vitessStatement.close();
}

}
return dbEngine;
}
Expand Down
5 changes: 1 addition & 4 deletions java/jdbc/src/main/java/io/vitess/jdbc/VitessDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@
*/
public class VitessDriver implements Driver {

/* Get actual class name to be printed on */
private static Logger logger = Logger.getLogger(VitessDriver.class.getName());

static {
try {
DriverManager.registerDriver(new VitessDriver());
Expand Down Expand Up @@ -73,7 +70,7 @@ public Connection connect(String url, Properties info) throws SQLException {
* TODO: Write a better regex
*/
@Override
public boolean acceptsURL(String url) throws SQLException {
public boolean acceptsURL(String url) {
return null != url && url.startsWith(Constants.URL_PREFIX);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.logging.Logger;

import io.vitess.client.Context;
import io.vitess.client.VTGateConnection;
Expand All @@ -70,7 +69,6 @@
public class VitessPreparedStatement extends VitessStatement implements PreparedStatement {

/* Get actual class name to be printed on */
private static Logger logger = Logger.getLogger(VitessPreparedStatement.class.getName());
private final String sql;
private final Map<String, Object> bindVariables;
/**
Expand Down Expand Up @@ -394,7 +392,7 @@ public void addBatch() throws SQLException {
vtGateConn = this.vitessConnection.getVtGateConn();

this.retrieveGeneratedKeys = true; // mimicking mysql-connector-j
/**
/*
* Current api does not support single query and multiple bindVariables list.
* So, List of the query is created to match the bindVariables list.
*/
Expand Down Expand Up @@ -466,9 +464,6 @@ private int calculateParameterCount() throws SQLException {
continue; // inline quote escape
}

inQuotes = !inQuotes;
currentQuoteChar = 0;
} else if (((c == '\'') || (c == '"')) && c == currentQuoteChar) {
inQuotes = !inQuotes;
currentQuoteChar = 0;
}
Expand Down
6 changes: 1 addition & 5 deletions java/jdbc/src/main/java/io/vitess/jdbc/VitessResultSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import java.util.Calendar;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import javax.sql.rowset.serial.SerialClob;

import io.vitess.client.cursor.Cursor;
Expand All @@ -61,9 +60,6 @@
*/
public class VitessResultSet implements ResultSet {

/* Get actual class name to be printed on */
private static Logger logger = Logger.getLogger(VitessResultSet.class.getName());

private Cursor cursor;
private List<FieldWithMetadata> fields;
private VitessStatement vitessStatement;
Expand Down Expand Up @@ -765,7 +761,7 @@ public Timestamp getTimestamp(String columnLabel, Calendar cal) throws SQLExcept
return getTimestamp(columnIndex, cal);
}

public boolean isClosed() throws SQLException {
public boolean isClosed() {
return this.closed;
}

Expand Down
22 changes: 9 additions & 13 deletions java/jdbc/src/main/java/io/vitess/jdbc/VitessStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;

import io.vitess.client.Context;
import io.vitess.client.Proto;
Expand All @@ -48,8 +47,6 @@
*/
public class VitessStatement implements Statement {
protected static final String[] ON_DUPLICATE_KEY_UPDATE_CLAUSE = new String[] { "ON", "DUPLICATE", "KEY", "UPDATE" };
/* Get actual class name to be printed on */
private static Logger logger = Logger.getLogger(VitessStatement.class.getName());
protected VitessResultSet vitessResultSet;
protected VitessConnection vitessConnection;
protected boolean closed;
Expand Down Expand Up @@ -268,9 +265,8 @@ public SQLWarning getWarnings() throws SQLException {
/**
* Clear the warnings - Not saving Warnings
*
* @throws SQLException
*/
public void clearWarnings() throws SQLException {
public void clearWarnings() {
//no-op
}

Expand Down Expand Up @@ -316,7 +312,7 @@ public VitessConnection getConnection() throws SQLException {
return vitessConnection;
}

public boolean isClosed() throws SQLException {
public boolean isClosed() {
return this.closed;
}

Expand Down Expand Up @@ -376,15 +372,15 @@ public ResultSet getGeneratedKeys() throws SQLException {
}
} else if (this.batchGeneratedKeys != null) {
long totalAffected = 0;
for (int i = 0; i < this.batchGeneratedKeys.length; i++) {
long rowsAffected = this.batchGeneratedKeys[i][1];
for (long[] batchGeneratedKey : this.batchGeneratedKeys) {
long rowsAffected = batchGeneratedKey[1];
totalAffected += rowsAffected;
}
data = new String[(int) totalAffected][1];
int idx = 0;
for (int i = 0; i < this.batchGeneratedKeys.length; i++) {
long insertId = this.batchGeneratedKeys[i][0];
long rowsAffected = this.batchGeneratedKeys[i][1];
for (long[] batchGeneratedKey : this.batchGeneratedKeys) {
long insertId = batchGeneratedKey[0];
long rowsAffected = batchGeneratedKey[1];
for (int j = 0; j < rowsAffected; j++) {
data[idx++][0] = String.valueOf(insertId + j);
}
Expand Down Expand Up @@ -591,7 +587,7 @@ protected void checkSQLNullOrEmpty(String sql) throws SQLException {
protected int[] generateBatchUpdateResult(List<CursorWithError> cursorWithErrorList, List<String> batchedArgs)
throws BatchUpdateException {
int[] updateCounts = new int[cursorWithErrorList.size()];
ArrayList<long[]> generatedKeys = new ArrayList<long[]>();
ArrayList<long[]> generatedKeys = new ArrayList<>();

Vtrpc.RPCError rpcError = null;
String batchCommand = null;
Expand Down Expand Up @@ -663,7 +659,7 @@ protected void checkAndBeginTransaction() throws SQLException {
if (!(this.vitessConnection.getAutoCommit() || this.vitessConnection.isInTransaction())) {
Context context = this.vitessConnection.createContext(this.queryTimeoutInMillis);
VTGateConnection vtGateConn = this.vitessConnection.getVtGateConn();
Cursor cursor = vtGateConn.execute(context,"begin",null,this.vitessConnection.getVtSession()).checkedGet();
vtGateConn.execute(context,"begin",null,this.vitessConnection.getVtSession()).checkedGet();
}
}

Expand Down
Loading