Skip to content

Commit

Permalink
Return correct jdbc and driver versions
Browse files Browse the repository at this point in the history
  • Loading branch information
kornilova203 committed Oct 18, 2018
1 parent d4593ab commit 4e04b79
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 33 deletions.
8 changes: 5 additions & 3 deletions driver/src/main/java/com/dbschema/CassandraConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@

public class CassandraConnection implements Connection {
private final Session session;
private CassandraJdbcDriver driver;
private boolean isClosed = false;
private boolean isReadOnly = false;

CassandraConnection(Session session) {
CassandraConnection(Session session, CassandraJdbcDriver cassandraJdbcDriver) {
this.session = session;
driver = cassandraJdbcDriver;
}

public String getCatalog() throws SQLException {
Expand Down Expand Up @@ -105,7 +107,7 @@ public boolean isClosed() {
@Override
public DatabaseMetaData getMetaData() throws SQLException {
checkClosed();
return new CassandraMetaData(this);
return new CassandraMetaData(this, driver);
}

@Override
Expand Down Expand Up @@ -301,7 +303,7 @@ private void checkClosed() throws SQLException {
}

@Override
public void setSchema(String schema) throws SQLException {
public void setSchema(String schema) {
setCatalog(schema);
}

Expand Down
35 changes: 11 additions & 24 deletions driver/src/main/java/com/dbschema/CassandraJdbcDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public Connection connect(String url, Properties info) throws SQLException {
Cluster cluster = clientURI.createCluster();
Session session = cluster.connect( clientURI.getKeyspace() );

return new CassandraConnection(session);
return new CassandraConnection(session, this);
} catch (UnknownHostException e) {
throw new SQLException( e.getMessage(), e);
}
Expand All @@ -54,52 +54,39 @@ public Connection connect(String url, Properties info) throws SQLException {

/**
* URLs accepted are of the form: jdbc:cassandra://host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[keyspace][?options]]
*
* @see java.sql.Driver#acceptsURL(java.lang.String)
*/
@Override
public boolean acceptsURL(String url) throws SQLException {
public boolean acceptsURL(String url) {
return url.startsWith(PREFIX);
}

/**
* @see java.sql.Driver#getPropertyInfo(java.lang.String, java.util.Properties)
*/
@Override
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException
{
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) {
return null;
}

/**
* @see java.sql.Driver#getMajorVersion()
*/
String getVersion() {
return "1.2.3-SNAPSHOT";
}

@Override
public int getMajorVersion()
{
public int getMajorVersion() {
return 1;
}

/**
* @see java.sql.Driver#getMinorVersion()
*/
@Override
public int getMinorVersion()
{
return 0;
public int getMinorVersion() {
return 23;
}

/**
* @see java.sql.Driver#jdbcCompliant()
*/
@Override
public boolean jdbcCompliant() {
return true;
}

@Override
public Logger getParentLogger() throws SQLFeatureNotSupportedException {
return null;
throw new SQLFeatureNotSupportedException();
}

}
14 changes: 8 additions & 6 deletions driver/src/main/java/com/dbschema/CassandraMetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
public class CassandraMetaData implements DatabaseMetaData {

private final CassandraConnection connection;
private CassandraJdbcDriver driver;

CassandraMetaData(CassandraConnection connection) {
CassandraMetaData(CassandraConnection connection, CassandraJdbcDriver driver) {
this.connection = connection;
this.driver = driver;
}

@Override
Expand Down Expand Up @@ -109,15 +111,15 @@ public String getDriverName() {
}

public String getDriverVersion() {
return "1.2.3-SNAPSHOT";
return driver.getVersion();
}

public int getDriverMajorVersion() {
return 1;
return driver.getMajorVersion();
}

public int getDriverMinorVersion() {
return 23;
return driver.getMinorVersion();
}

public boolean usesLocalFiles() throws SQLException {
Expand Down Expand Up @@ -719,12 +721,12 @@ public int getDatabaseMinorVersion() {

@Override
public int getJDBCMajorVersion() {
return 1;
return 4;
}

@Override
public int getJDBCMinorVersion() {
return 0;
return 2;
}

@Override
Expand Down

0 comments on commit 4e04b79

Please sign in to comment.