mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-27 04:54:21 +01:00
Implement getURL() for JDBC4DatabaseMetaData
This commit is contained in:
@@ -13,6 +13,7 @@ import org.github.tursodatabase.utils.LoggerFactory;
|
||||
public class LimboConnection {
|
||||
private static final Logger logger = LoggerFactory.getLogger(LimboConnection.class);
|
||||
|
||||
private final String url;
|
||||
private final long connectionPtr;
|
||||
private final AbstractDB database;
|
||||
private boolean closed;
|
||||
@@ -28,6 +29,7 @@ public class LimboConnection {
|
||||
* @param filePath path to file
|
||||
*/
|
||||
public LimboConnection(String url, String filePath, Properties properties) throws SQLException {
|
||||
this.url = url;
|
||||
this.database = open(url, filePath, properties);
|
||||
this.connectionPtr = this.database.connect();
|
||||
}
|
||||
@@ -41,6 +43,10 @@ public class LimboConnection {
|
||||
if (isClosed()) throw new SQLException("database connection closed");
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void close() throws SQLException {
|
||||
if (isClosed()) {
|
||||
return;
|
||||
|
||||
@@ -368,4 +368,8 @@ public class JDBC4Connection implements Connection {
|
||||
// TODO: add support for busyTimeout
|
||||
return 0;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return this.connection.getUrl();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public class JDBC4DatabaseMetaData implements DatabaseMetaData {
|
||||
|
||||
@Override
|
||||
public String getURL() throws SQLException {
|
||||
return "";
|
||||
return connection.getUrl();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -786,6 +786,7 @@ public class JDBC4DatabaseMetaData implements DatabaseMetaData {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SkipNullableCheck
|
||||
public Connection getConnection() throws SQLException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package org.github.tursodatabase.jdbc4;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.github.tursodatabase.TestUtils;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class JDBC4DatabaseMetaDataTest {
|
||||
|
||||
private JDBC4Connection connection;
|
||||
private JDBC4DatabaseMetaData metaData;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() throws Exception {
|
||||
String filePath = TestUtils.createTempFile();
|
||||
String url = "jdbc:sqlite:" + filePath;
|
||||
connection = new JDBC4Connection(url, filePath, new Properties());
|
||||
metaData = new JDBC4DatabaseMetaData(connection);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getURLShouldReturnNonEmptyString() throws Exception{
|
||||
assertFalse(metaData.getURL().isEmpty());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user