문제

나는 Java를 활용하고 있습니다 sqlitejdbc sqlite와 함께 일합니다. 주어진 테이블의 열 이름에 액세스해야하며 다음 명령으로이를 달성 할 수 있음을 발견했습니다.

pragma table_info(myTable)

그러나 다음을 시도 할 때 오류가 발생합니다.

PreparedStatement _pstmt =
    this._DBConnection.prepareStatement("pragma table_info( '?' );",
         new String[] {_tableName} );

java.sql.sqlexception : nyi

나는 NYI가 무엇을 의미하는지 전혀 모른다. 또한, 내가하려는 일을 할 수 있는지 확실하지 않다. 열 이름을 얻는 방법에 대한 제안이 있습니까?

도움이 되었습니까?

해결책

NYI는 "아직 구현되지 않았다"는 것을 의미합니다.

"Pragma table_info"명령은 아마도 준비된 진술로 직접 실행할 수 없을 것 같아요.

SQLITE JDBC 드라이버, 클래스에 대한 코드에서 Pragma 문장을 실행하는 예가 있습니다. org.sqlite.metadata, 다음과 같은 방법 getColumns() 그리고 getPrimaryKeys().

코드를 발췌 한 후 여기에 게시 할 수는 없습니다. 그렇게하면 StackoverFlow가 사용하는 Creative Commons 라이센스와 호환되지 않기 때문입니다. 그러니 그 링크로 가서 살펴보십시오.

다른 팁

이 발췌 한 코드가 있습니다 sqlitejdbc 소스 코드:

 public PreparedStatement prepareStatement(String sql, int autoC)
        throws SQLException { throw new SQLException("NYI"); }
    public PreparedStatement prepareStatement(String sql, int[] colInds)
        throws SQLException { throw new SQLException("NYI"); }
    public PreparedStatement prepareStatement(String sql, String[] colNames)
        throws SQLException { throw new SQLException("NYI"); }
    public PreparedStatement prepareStatement(String sql, int rst, int rsc) 
                                throws SQLException {
        return prepareStatement(sql, rst, rsc,
                                ResultSet.CLOSE_CURSORS_AT_COMMIT);
    }

NYI는 "아직 구현되지 않았다"는 것을 의미합니다.

Pragma가 작동하지 않으면

sqlite> CREATE TABLE a(col1, col2, col3);
sqlite> CREATE TABLE b(w, x, y, z);
sqlite> SELECT * FROM sqlite_master;
table|a|a|2|CREATE TABLE a(col1, col2, col3)
table|b|b|3|CREATE TABLE b(w, x, y, z)

sqlite> SELECT sql FROM sqlite_master;
CREATE TABLE a(col1, col2, col3)
CREATE TABLE b(w, x, y, z)

실제 열 정의를 가져올 수 있습니다 sqlite_master 테이블과 직접 구문 분석하십시오.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top