extracting Check Constraint Search Conditions Using JDBC
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: extracting Check Constraint Search Conditions Using JDBC

  1. #1
    Join Date
    Feb 2005
    Posts
    4

    extracting Check Constraint Search Conditions Using JDBC

    I am trying to extract the search conditions of check constraints from a few tables on Oracle 9.2.0.1. and Java 1.4.2.

    Here is my code:

    Vector checks = new Vector();
    String sql = "select C.COLUMN_NAME, U.SEARCH_CONDITION ";
    sql = sql + "from USER_CONSTRAINTS U, USER_CONS_COLUMNS C ";
    sql = sql + "where U.TABLE_NAME = ";
    sql = sql + "'" + table + "' ";
    sql = sql + "and U.CONSTRAINT_TYPE = 'C' ";

    rs = client.processQuery(sql); //rs is a ResultSet and client is a JDBCClient

    while (rs.next()) {
    System.out.println(rs.getLong("SEARCH_CONDITION")); //this throws an SQLException
    checks.addElement(rs.getString("COLUMN_NAME")); //this works fine
    }


    here is the SQLException that I get:

    java.sql.SQLException: Message file 'oracle.jdbc.dbaccess.Messages' is missing.
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:210)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:273)
    at oracle.jdbc.dbaccess.DBDataSetImpl.getStreamItem(DBDataSetImpl.java:1087)
    at oracle.jdbc.driver.OracleStatement.getBytesInternal(OracleStatement.java:2489)
    at oracle.jdbc.driver.OracleStatement.getLongValue(OracleStatement.java:3170)
    at oracle.jdbc.driver.OracleResultSetImpl.getLong(OracleResultSetImpl.java:335)
    at oracle.jdbc.driver.OracleResultSet.getLong(OracleResultSet.java:1432)
    at edu.wpi.cs.dsrg.xmldb.common.ASG.XAT2ASG.getKeysAndConstraints(XAT2ASG.java:740) <-- this is where the System.out.println(rs.getLong("SEARCH_CONDITION")); call is.
    at edu.wpi.cs.dsrg.xmldb.common.ASG.XAT2ASG.convertXAT2ASGs(XAT2ASG.java:302)
    at edu.wpi.cs.dsrg.xmldb.UFilter.test.TestXAT2ASG.main(TestXAT2ASG.java:53)


    When I get the ResultSet's metadata, it tells me that there are two columns and the second is named "SEARCH_CONDITION" and is of type "LONG" but I cant get it out, no matter what I try.
    Share on Google+

  2. #2
    Join Date
    May 2000
    Location
    ATLANTA, GA, USA
    Posts
    3,136
    You cannot just use "select" statement for reading long col in JAVA.

    You should use PreparedStatement.setAsciiStream(..) method.
    For reading you must use ResultSet.getBytes(...).


    Tamil
    Share on Google+

  3. #3
    Join Date
    Feb 2005
    Posts
    4
    Can you please elaborate on how to get my sql statement into the PreparedStatement using the setAsciiStream() function?

    I tried putting my sql string into StreamBufferInputStream and then passing it into the PreparedStatement.setAsciiStream() function, but then PreparedStatement.executeQuery() resulted in an error, which said the SQL command was invalid.
    Share on Google+

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width