Thread: rsetMetaData.getColumnCount();

rsetMetaData.getColumnCount();

From
"sc0698"
Date:
       rsetMetaData = rset.getMetaData();
       numCols = rsetMetaData.getColumnCount();

getColumnCount() error:

java.lang.NullPointerException

 at
org.postgresql.jdbc2.AbstractJdbc2ResultSetMetaData.getColumnCount(AbstractJ
dbc2ResultSetMetaData.java:34)





Re: rsetMetaData.getColumnCount();

From
Barry Lind
Date:
Can you provide a test case that demonstrates the problem?  Also, have
you tried the latest driver to see if this is already fixed?

thanks,
--Barry

sc0698 wrote:
>        rsetMetaData = rset.getMetaData();
>        numCols = rsetMetaData.getColumnCount();
>
> getColumnCount() error:
>
> java.lang.NullPointerException
>
>  at
> org.postgresql.jdbc2.AbstractJdbc2ResultSetMetaData.getColumnCount(AbstractJ
> dbc2ResultSetMetaData.java:34)
>
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: the planner will ignore your desire to choose an index scan if your
>       joining column's datatypes do not match
>




Re: rsetMetaData.getColumnCount();

From
"sc0698"
Date:
the jdbc driver version :
 7.4beta3(build 209)(2003-09-12)   JDBC3 JDK 1.4 includes support for SSL

database verion:
7.4beta3  and 7.3.4


In the create2DArray  I want to use  rsetMetaData.getColumnCount(),


    SQL.append("{?=call Fuc_Test4Query(");
    SQL.append("'"+name+"','"+value+"'");
    SQL.append(")}");
    m_query = SQL;

  public boolean executeProc() {
    boolean ret = false;

    Connection conn = null;
    CallableStatement cstmt = null;

    if ( (m_query != null) && !m_query.equals("")) {
      conn = getConnection();

      if (conn != null) {
        try {
          conn.setAutoCommit(false);

          cstmt = conn.prepareCall(m_query);

          if (m_flag.toUpperCase() != UPDATE) {
            cstmt.registerOutParameter(1, Types.OTHER);
            cstmt.execute();

//            ResultSet resultSet = cstmt.executeQuery();

            ResultSet resultSet = (ResultSet)cstmt.getObject(1);

// org.postgresql.PGRefCursorResultSet refcurs
  //  = (PGRefCursorResultSet) con.getObject(1);
//String cursorName = refcurs.getRefCursor();

            //resultset to 2D Array
            m_twoDArray = create2DArray(resultSet);

            resultSet.close();
          }
          else {
            cstmt.registerOutParameter(1, Types.INTEGER);
            cstmt.execute();
              m_return = cstmt.getInt(1);
          }

          conn.commit();

          // close CallableStatement handle
          cstmt.close();
          conn.close();

          ret = true;
        }
        catch (SQLException e) {
          e.printStackTrace();

          try {
            if (cstmt != null) {
              cstmt.close();
            }

            conn.close();
          }
          catch (Exception se) {
          }

          throw new RuntimeException(e.getMessage());
        }
      }
    }

    return ret;
  }



Re: rsetMetaData.getColumnCount();

From
Barry Lind
Date:
Please send a test case that I can compile and run on my machine to
debug this problem.  The code you included below doesn't even have the
call to getColumnCount().

thanks,
--Barry

sc0698 wrote:
> the jdbc driver version :
>  7.4beta3(build 209)(2003-09-12)   JDBC3 JDK 1.4 includes support for SSL
>
> database verion:
> 7.4beta3  and 7.3.4
>
>
> In the create2DArray  I want to use  rsetMetaData.getColumnCount(),
>
>
>     SQL.append("{?=call Fuc_Test4Query(");
>     SQL.append("'"+name+"','"+value+"'");
>     SQL.append(")}");
>     m_query = SQL;
>
>   public boolean executeProc() {
>     boolean ret = false;
>
>     Connection conn = null;
>     CallableStatement cstmt = null;
>
>     if ( (m_query != null) && !m_query.equals("")) {
>       conn = getConnection();
>
>       if (conn != null) {
>         try {
>           conn.setAutoCommit(false);
>
>           cstmt = conn.prepareCall(m_query);
>
>           if (m_flag.toUpperCase() != UPDATE) {
>             cstmt.registerOutParameter(1, Types.OTHER);
>             cstmt.execute();
>
> //            ResultSet resultSet = cstmt.executeQuery();
>
>             ResultSet resultSet = (ResultSet)cstmt.getObject(1);
>
> // org.postgresql.PGRefCursorResultSet refcurs
>   //  = (PGRefCursorResultSet) con.getObject(1);
> //String cursorName = refcurs.getRefCursor();
>
>             //resultset to 2D Array
>             m_twoDArray = create2DArray(resultSet);
>
>             resultSet.close();
>           }
>           else {
>             cstmt.registerOutParameter(1, Types.INTEGER);
>             cstmt.execute();
>               m_return = cstmt.getInt(1);
>           }
>
>           conn.commit();
>
>           // close CallableStatement handle
>           cstmt.close();
>           conn.close();
>
>           ret = true;
>         }
>         catch (SQLException e) {
>           e.printStackTrace();
>
>           try {
>             if (cstmt != null) {
>               cstmt.close();
>             }
>
>             conn.close();
>           }
>           catch (Exception se) {
>           }
>
>           throw new RuntimeException(e.getMessage());
>         }
>       }
>     }
>
>     return ret;
>   }
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
>       subscribe-nomail command to majordomo@postgresql.org so that your
>       message can get through to the mailing list cleanly
>