change
This commit is contained in:
parent
16530a22eb
commit
74eb320337
|
@ -1,33 +0,0 @@
|
||||||
import com.taosdata.jdbc.TSDBDriver;
|
|
||||||
|
|
||||||
import java.sql.*;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
public class TestTSDBDatabaseMetaData {
|
|
||||||
|
|
||||||
public static void main(String[] args) throws SQLException {
|
|
||||||
Connection connection = null;
|
|
||||||
DatabaseMetaData dbMetaData;
|
|
||||||
ResultSet resSet;
|
|
||||||
try {
|
|
||||||
Class.forName("com.taosdata.jdbc.TSDBDriver");
|
|
||||||
Properties properties = new Properties();
|
|
||||||
properties.setProperty(TSDBDriver.PROPERTY_KEY_HOST, "localhost");
|
|
||||||
connection = DriverManager.getConnection("jdbc:TAOS://localhost:0/", properties);
|
|
||||||
dbMetaData = connection.getMetaData();
|
|
||||||
resSet = dbMetaData.getCatalogs();
|
|
||||||
while(resSet.next()) {
|
|
||||||
for (int i = 1; i <= resSet.getMetaData().getColumnCount(); i++) {
|
|
||||||
System.out.printf("dbMetaData.getCatalogs(%d) = %s\n", i, resSet.getString(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
resSet.close();
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
if (null != connection) {
|
|
||||||
connection.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -657,7 +657,14 @@ public class TSDBDatabaseMetaDataTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getCatalogs() throws SQLException {
|
public void getCatalogs() throws SQLException {
|
||||||
Assert.assertNotNull(metaData.getCatalogs());
|
ResultSet catalogs = metaData.getCatalogs();
|
||||||
|
ResultSetMetaData meta = catalogs.getMetaData();
|
||||||
|
while (catalogs.next()) {
|
||||||
|
for (int i = 1; i <= meta.getColumnCount(); i++) {
|
||||||
|
System.out.print(meta.getColumnLabel(i) + ": " + catalogs.getString(i));
|
||||||
|
}
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue