Skip to content

Commit

Permalink
add com.jd.jdbc.vitess.resultset.DatabaseMetaDataResultSet.getStateme…
Browse files Browse the repository at this point in the history
…nt func

add java.sql.ResultSetMetaData.isCaseSensitive func
  • Loading branch information
wlx5575 committed Jul 31, 2023
1 parent ee72578 commit eb3dcef
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ private VtResultSet toVtResultSet(final boolean isQuery, final Statement stateme
.setColumnLength(metaData.getColumnDisplaySize(col))
.setDecimals(metaData.getScale(col))
.setIsSigned(metaData.isSigned(col))
.setIsCaseSensitive(metaData.isCaseSensitive(col))
.setType(queryType);
fields[idx] = fieldBuilder.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,4 @@ public boolean isAutoIncrement(int column) throws SQLException {
throw new SQLFeatureNotSupportedException();
}

@Override
public boolean isCaseSensitive(int column) throws SQLException {
throw new SQLFeatureNotSupportedException();
}

}
5 changes: 5 additions & 0 deletions src/main/java/com/jd/jdbc/vitess/VitessResultSetMetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,9 @@ public String getColumnClassName(int column) throws SQLException {
}
return getField(column).getJdbcClassName();
}

@Override
public boolean isCaseSensitive(int column) throws SQLException {
return getField(column).getIsCaseSensitive();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import java.sql.SQLFeatureNotSupportedException;
import java.sql.SQLWarning;
import java.sql.SQLXML;
import java.sql.Statement;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.Calendar;
Expand Down Expand Up @@ -91,11 +90,6 @@ public final Reader getCharacterStream(final String columnLabel) throws SQLExcep
throw new SQLFeatureNotSupportedException();
}

@Override
public final Statement getStatement() throws SQLException {
throw new SQLFeatureNotSupportedException();
}

@Override
public final Array getArray(final int columnIndex) throws SQLException {
throw new SQLFeatureNotSupportedException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.ArrayList;
Expand Down Expand Up @@ -90,7 +91,7 @@ private DatabaseMetaDataObject generateDatabaseMetaDataObject(final int tableCat
if (tableCatIndex == i) {
String tableCat = resultSet.getString(i);
tableCat = KeyspaceUtil.getLogicSchema(tableCat);
if (tableCat.equals("_vt")) {
if ("_vt".equals(tableCat)) {
return null;
}
result.addObject(tableCat);
Expand Down Expand Up @@ -279,6 +280,12 @@ public Date getDate(final String columnLabel) throws SQLException {
return getDate(findColumn(columnLabel));
}

@Override
public Statement getStatement() throws SQLException {
checkClosed();
return resultSet.getStatement();
}

@Override
public Time getTime(final int columnIndex) throws SQLException {
checkClosed();
Expand Down
3 changes: 3 additions & 0 deletions src/main/proto/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,9 @@ message Field {

//isSigned
bool is_signed = 14;

//isCaseSensitive
bool is_case_sensitive = 15;
}

// Row is a database row.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,20 +178,13 @@ public void getTypeInfo() throws Exception {
try (ResultSet info = connection.getMetaData().getTypeInfo()) {
//Printing the column name and size
while (info.next()) {
System.out.println("Data type name: " + info.getString("TYPE_NAME"));
System.out.println("Integer value representing this datatype: " + info.getInt("DATA_TYPE"));
System.out.println("Maximum precision of this datatype: " + info.getInt("PRECISION"));
if (info.getBoolean("CASE_SENSITIVE")) {
System.out.println("Current datatype is case sensitive ");
} else {
System.out.println("Current datatype is not case sensitive ");
}
if (info.getBoolean("AUTO_INCREMENT")) {
System.out.println("Current datatype can be used for auto increment ");
} else {
System.out.println("Current datatype can not be used for auto increment ");
}
info.getString("TYPE_NAME");
info.getInt("DATA_TYPE");
info.getInt("PRECISION");
info.getBoolean("CASE_SENSITIVE");
info.getBoolean("AUTO_INCREMENT");
}
Statement statement = info.getStatement();
}
}

Expand Down

0 comments on commit eb3dcef

Please sign in to comment.