metatest.java
来自「nanjing university cs 的java课件。 对新手很有用。付」· Java 代码 · 共 58 行
JAVA
58 行
/*
* Created on 2004-8-9
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package com.sanshang.jdbc;
/**
* @author WTQ
*
* TODO To change the template for this generated type comment go to Window -
* Preferences - Java - Code Style - Code Templates
*/
import java.sql.*;
public class MetaTest {
public static void main(String args[]) throws ClassNotFoundException,
SQLException {
Connection conn = null;
try {
// Load database driver
Class.forName(DBInfo.driver);
// Make connection
conn = DriverManager.getConnection(DBInfo.dbURI, DBInfo.user,
DBInfo.password);
// Get the database meta data
DatabaseMetaData dmd = conn.getMetaData();
// Display information about the database
// product and driver
if (dmd == null) {
System.out.println("Database meta data not available");
} else {
System.out.println("Database Product Name : "
+ dmd.getDatabaseProductName());
System.out.println("Database Product Version: "
+ dmd.getDatabaseProductVersion());
System.out.println("Database Driver Name : "
+ dmd.getDriverName());
System.out.println("Database Driver Version : "
+ dmd.getDriverVersion());
}
} finally {
if (conn != null) {
try {
conn.close();
} catch (SQLException sqlEx) {
// ignore
}
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?