日期:2014-05-16 浏览次数:20414 次
DatabaseMetaData md = this.jdbcTemplate.getDataSource().getConnection().getMetaData(); System.out.println(md.getDatabaseProductName()); System.out.println(md.getDatabaseProductVersion());
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); }