import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
public class Main {
public static void main(String[] args) throws Exception {
Connection conn = getConnection();
DatabaseMetaData mtdt = conn.getMetaData();
System.out.println("URL in use: " + mtdt.getURL());
System.out.println("User name: " + mtdt.getUserName());
System.out.println("DBMS name: " + mtdt.getDatabaseProductName());
System.out.println("DBMS version: " + mtdt.getDatabaseProductVersion());
System.out.println("Driver name: " + mtdt.getDriverName());
System.out.println("Driver version: " + mtdt.getDriverVersion());
System.out.println("supp. SQL Keywords: " + mtdt.getSQLKeywords());
conn.close();
}
private static Connection getConnection() throws Exception {
Class.forName("org.hsqldb.jdbcDriver");
String url = "jdbc:hsqldb:mem:data/tutorial";
return DriverManager.getConnection(url, "sa", "");
}
}
|