import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
public class Main {
public static void main(String[] args) throws Exception {
try {
String url = "jdbc:odbc:yourdatabasename";
String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
String user = "guest";
String password = "guest";
Class.forName(driver);
Connection connection = DriverManager.getConnection(url, user, password);
DatabaseMetaData meta = connection.getMetaData();
System.out.println("We are using " + meta.getDatabaseProductName());
System.out.println("Version is " + meta.getDatabaseProductVersion() );
connection.close();
} catch (Exception e) {
System.err.println(e);
}
}
}
|