Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4135304

Retreiving Float/Double data thru JDBC-ODBC bridge causes an error.

XMLWordPrintable

    • 1.1.6
    • x86
    • windows_95, windows_nt
    • Not verified



        Name: eyC74480 Date: 05/05/98


        Retreiving Float/Double data by java.sql.ResuleSetMetaData#getObject()
        causes an error with the Windows error dialog.
        This does not occur with the -nojit option. While the Float case
        always causes an error dialog to be displayed, the Double case
        sometimes displays null without the error dialog. Unfortunately,
        we haven't found what causes the error dialog and the null message
        for the Double case.
         
        Following code demonstrates the problem. In prior to running the
        Java program, register a MS-Access MDB file by the name 'access'
        with the control panel. Although I do not attach the sample MDB
        file with this submission because of the limitation of your Web
        page, I can send you the sample MDB file by e-mail if you ask me
        to.
         
        import java.lang.*;
        import java.sql.*;
         
        public class rs1
        {
                public static void main(String arg[])
                {
                        try {
                                /* load JDBCDriverClass */
                                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
         
                                Connection con = null;
                                Statement stmt = null;
                                ResultSet rs = null;
         
                                con = DriverManager.getConnection("jdbc:odbc:access", "", "");
         
                                stmt = con.createStatement();
         
        // stmt.execute("SELECT c_double FROM test");
                                stmt.execute("SELECT c_float FROM test");
                                rs = stmt.getResultSet();
                                printResult(rs);
         
                                con.rollback();
                                con.close();
         
                        } catch (Exception ex) {
                                ex.printStackTrace();
                        }
                }
         
                static void printResult(ResultSet rs) {
                        try {
                                ResultSetMetaData rsmd = null;
                                Object w_obj = null;
                                int colNum;
                                int j = 0;
         
                                if (rs == null) {
                                        System.out.println("No ResultSet");
                                        return;
                                } else {
                                        rsmd = rs.getMetaData();
                                        colNum = rsmd.getColumnCount();
                                }
         
                                System.out.println("** Display data **");
                                while (true)
                                {
                                        if (rs.next() == false) {
                                                break;
                                        }
         
                                        System.out.println("[" + (j+1) + "Step]");
                                        for (int i = 1; i <= colNum; i++) {
                                                System.out.print(" "+rsmd.getColumnName(i)+"=");
                                                w_obj = rs.getObject(i);
                                                System.out.println(w_obj);
                                        }
                                        j++;
                                }
                                System.out.println("Total Step:"+j+"!$Column Count:"+colNum);
                        } catch (Exception ex) {
                                ex.printStackTrace();
                        }
                }
        }
        (Review ID: 29149)
        ======================================================================

              dviswanasunw Deepa Viswanathan (Inactive)
              eyusunw Ellis Yu (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: