Oracle JDBCãã©ã¤ãã§LONGåã«ã¢ã¯ã»ã¹ããéã®æ³¨æç¹
LONGåãªããã¯ããéæ¨å¥¨ã§æ®éã¯BLOB使ãããã»ã¨ãã©åé¡ã«ã¯ãªããªãå 容ãªã®ã§ããã
Oracleã®ãã¼ã¿ãã£ã¯ã·ã§ããªãã¼ãã«ã®ä¸ã¤ALL_TAB_COLUMNSï¼USER_TAB_COLUMNSï¼ã®DATA_DEFAULTåã¯ãªãã¨LONGåã§ãããã«ã¢ã¯ã»ã¹ããã¨ãã«ãã®åé¡ã«ã¯ã¾ã£ã¦2æéã»ã©æ失ããã®ã§ã¡ã¢ãã¦ããã
ãOracle JDBCãã©ã¤ãã§LONGåãå«ããã¼ãã«ã«ã¢ã¯ã»ã¹ããå ´åã¯ãResultSetãããã¼ã¿ãåå¾ããã¨ãLONGåãä¸çªæåã«åå¾ããªããã°ãªããªãã
ãªãããã ããããã
å ·ä½çã«ã¯ä»¥ä¸ã®ãããªç¾è±¡ã
final String SQL_COLUMNINFO = "SELECT " + "col.column_name COLUMN_NAME, " + "col.data_default DATA_DEFAULT, " + //ããã¤ãLONGå "co.comments COMMENTS " + "FROM " + "user_tab_columns col " + "WHERE " + "col.table_name = 'HOGE' " + "ORDER BY " + "col.table_name, " + "col.column_id "; Statement stmt = null; ResultSet rs = null; try { stmt = conn.createStatement(); rs = stmt.executeQuery(SQL_COLUMNINFO); while(rs.next()) { String columnName = rs.getString("COLUMN_NAME"); String comments = rs.getString("COMMENTS"); String dataDefault = rs.getString("DATA_DEFAULT"); //ããã§ä¾å¤çºç System.out.println(ColumnName + ':' + comments + ':' + dataDefault); } } finally { try { if(rs!=null) rs.close(); } catch (SQLException e) {} try { if(ps!=null) ps.close(); } catch (SQLException e) {} }
ä¸è¨ã®ãããªè¨è¿°ã ã¨ãgetString("DATA_DEFAULT") ã¨ããæç¹ã§ãORA-17027 ã¹ããªã¼ã ã¯ãã§ã«ã¯ãã¼ãºæ¸ã§ãããçºçãã
ããã¯ã以ä¸ã®ããã«ããã¨åé¡ãåé¿ã§ãã
final String SQL_COLUMNINFO = "SELECT " + "col.column_name COLUMN_NAME, " + "col.data_default DATA_DEFAULT, " + //ããã¤ãLONGå "co.comments COMMENTS " + "FROM " + "user_tab_columns col " + "WHERE " + "col.table_name = 'HOGE' " + "ORDER BY " + "col.table_name, " + "col.column_id "; Statement stmt = null; ResultSet rs = null; try { stmt = conn.createStatement(); rs = stmt.executeQuery(SQL_COLUMNINFO); while(rs.next()) { String dataDefault = rs.getString("DATA_DEFAULT"); //æåã«èªã String columnName = rs.getString("COLUMN_NAME"); String comments = rs.getString("COMMENTS"); System.out.println(ColumnName + ':' + comments + ':' + dataDefault); } } finally { try { if(rs!=null) rs.close(); } catch (SQLException e) {} try { if(ps!=null) ps.close(); } catch (SQLException e) {} }
Oracle Database JDBC開発者ガイドおよびリファレンスã«ã¯ãããã«ãLONGåã«å¾ã§ã¢ã¯ã»ã¹ãããã¨ãã¦ãããã¼ã¿ã¯ä½¿ç¨ã§ããããã©ã¤ãã¯ãã¹ããªã¼ã ãã¯ãã¼ãºããã¦ãã¾ãããã¨ã©ã¼ãæ»ãã¾ãããã¨æ¸ãã¦ãããã©ã
æ°ã¥ããªãããããªã®ã
ãã®Oracle JDBCãã©ã¤ãã®LONGåã«å¯¾ããå¶éã£ã¦ãOracle+Javaãªçéã§ã¯å¸¸èã¬ãã«ã®æåãªè©±ã ã£ããããã®ããªãï¼ã°ã°ã£ã¦ãå ¨ç¶åºã¦ããªãã£ããâ¦
2010/11/13 Javaã®ã³ã¼ãã«ä¸é¨èª¤ãããã£ãã®ã§ä¿®æ£ãã¾ãããã¾ããæç« ã®ä¸é¨ãä¿®æ£ãã¾ãã