|
Last-modified: 2005-01-13 (木) 21:45:57 (7421d)
どれもなんてことはないコードなんですけど、コピー&ペーストで使えるようにメモしておきます。 JavaVMのシステムプロパティを一覧 †webMethodsで、これをJavaサービスにして使っていたものを汎用化しました。ソートしてるだけですね(^^;; public static final String[][] getSystemProperties() { Properties props = System.getProperties(); List keyList = new ArrayList(props.keySet()); Collections.sort(keyList); int propsSize = keyList.size(); String[][] properties = new String[propsSize][2]; for (int i = 0; i < propsSize; i++) { String key = (String)keyList.get(i); properties[i][0] = key; properties[i][1] = props.getProperty(key); } return properties; } public static final void printlnSystemProperties() { String[][] sysProps = getSystemProperties(); int propSize = sysProps.length; for (int i = 0; i < propSize; i++) { System.out.println(sysProps[i][0] + "=" + sysProps[i][1]); } } VMで有効になっているJDBCドライバのバージョンはどれなの?チェック †try { //Oracle JDBC Driverをロード DriverManager.registerDriver(new OracleDriver()); //Connectionオブジェクトを作成 Connection conn = DriverManager.getConnection( "jdbc:oracle:thin:@oracledb:1521:dbname", "username", "password"); //JDBCおよびDBに関する情報取得 DatabaseMetaData meta = conn.getMetaData(); //DB製品名 String DB_Product_Name = meta.getDatabaseProductName(); //DB製品バージョン String DB_Product_Version = meta.getDatabaseProductVersion(); //JDBCドライババージョン String JDBC_Driver_Name = meta.getDriverName(); //JDBCドライバ製品名 String JDBC_Driver_Version = meta.getDriverVersion(); //Connectionオブジェクトをクローズ conn.close(); System.out.println("DB_Product_Name: " + DB_Product_Name); System.out.println("DB_Product_Version: " + DB_Product_Version); System.out.println("JDBC_Driver_Name: " + JDBC_Driver_Name); System.out.println("JDBC_Driver_Version: " + JDBC_Driver_Version); } catch (SQLException e) { e.printStackTrace(); } |