Hello

I am getting test failures as part of
converting jdbcapi/parameterMetadataJdbc30.java.

The behavior is different between the embedded and the n/w
client. Here are the results:

* Testing with org.apache.derby.jdbc.ClientDriver
getParameterType: 3
* Testing with org.apache.derby.jdbc.EmbeddedDriver
getParameterType: 2

Expected results should be getParameterType: 2

The problem is at the following piece of code:
/**
        *  test: the scale returned should be the one set by
registerOutParameter
        */
       public void testCallableStatementReturnedScale () throws SQLException {

               Statement stmt = createStatement();
               stmt.executeUpdate("create procedure
dummy_numeric_Proc(out a NUMERIC(30,15), out b NUMERIC(30,15))
language java parameter style java external name
'org.apache.derbyTesting.functionTests.tests.jdbcapi.parameterMetaDataJdbc30.dummy_numeric_Proc'");
               CallableStatement cs = prepareCall("CALL
dummy_numeric_Proc(?,?)");
               cs.registerOutParameter(1, Types.NUMERIC);
               cs.registerOutParameter(2, Types.NUMERIC,15);
               cs.execute();
               assertEquals("Unexpected parameter count", 2,
paramMetaData.getParameterCount());
               assertEquals("Unexpected parameter Type", 2,
cs.getParameterMetaData().getParameterType(1));

               cs.close();

I am attaching a testcase with this email.

Thanks,
Ramin Moazeni
/*
 * Main.java
 *
 */

import java.sql.*;

/**
 * Test <test purpose>
 * 
 * @author [EMAIL PROTECTED]
 * Moified for a new possible bug [6/12/07]
 * 
 */
public class Main {
    
    Connection con = null;

    /** Creates a new instance of Main */
    public Main() {
    }

    private org.apache.derby.drda.NetworkServerControl netServer;
      
    private void startServer() {
        try {
            netServer = new org.apache.derby.drda.NetworkServerControl
                (java.net.InetAddress.getByName("localhost"), 1527);
            java.io.PrintWriter consoleWriter = new java.io.PrintWriter
                (System.out, true);
            netServer.start(consoleWriter);
            boolean knowIfServerUp = false; // do we know if server is
            // ready to accept connections  
            int numTimes = 5;

            // Test to see if server is ready for connections, for 15 seconds.
            while(!knowIfServerUp && (numTimes >0)) {
                try {
                    // testing for connection to see if the network server
                    // is up and running if server is not ready yet, this
                    // method will throw an exception 
                    numTimes--;
                    netServer.ping();
                    knowIfServerUp = true;
                }
                catch(Exception e) {
                    System.out.println("[NsSample] Unable to obtain a " + 
                                       "connection to network server, " + 
                                       "trying again after 3000 ms.");
                    Thread.currentThread().sleep(3000);
                }
            }
        } catch (Exception e) {
            System.out.println("Error starting server: " + e.toString());
        }
    }
    
    private void shutdownServer() {
        try {
            netServer.shutdown();
        } catch (Exception e) {
            System.out.println("Error shuting down: " + e.toString());
        }
    }

    private void dropProcedure() {
        try {
            Statement st = con.createStatement();
            st.executeUpdate("drop procedure dummy_numeric_Proc");
            st.close();
        } catch (SQLException sqlE) {
            // expected
        } catch (Exception e) {
            System.out.println("Error dropping table: " + e.toString());
        }
    }

    
    private void doStuff() {
        Statement s = null; 
        ResultSet rs = null;

        try {
            	dropProcedure();

		con.createStatement().executeUpdate("create procedure dummy_numeric_Proc(out a NUMERIC(30,15), out b NUMERIC(30,15)) language java parameter style java external name 'org.apache.derbyTesting.functionTests.tests.jdbcapi.parameterMetaDataJdbc30.dummy_numeric_Proc'");
		CallableStatement cs = con.prepareCall("CALL dummy_numeric_Proc(?,?)");
                cs.registerOutParameter(1, Types.NUMERIC);
                cs.registerOutParameter(2, Types.NUMERIC,15);
                cs.execute();

		System.out.println("getParameterType: " + cs.getParameterMetaData().getParameterType(1));

        } catch (SQLException e) {
            	System.out.println("Error in doStuff: " + e.getSQLState() +
                               ": " + e);
            	while (e != null) {
                	e.printStackTrace();
                	e=e.getNextException();
            	}

        } finally {
            if (rs != null) {
                try { rs.close(); } catch (Exception e) {};
            }
            if (s != null) {
                try { s.close(); } catch (Exception e) {};
            }
        }


    }

    private void doBothDrivers(){
        Statement selectStatement = null;
        ResultSet rs = null;
        Statement st = null;

        String urls[] = {"jdbc:derby://localhost:1527/test1;create=true;"+
                         "territory=en_US",
                         "jdbc:derby:test1;create=true;territory=en_US"};
        String drivers[] = {"org.apache.derby.jdbc.ClientDriver",
                            "org.apache.derby.jdbc.EmbeddedDriver"};

        for (int dNo = 0; dNo < 2; dNo++) {
            try {
                Class.forName(drivers[dNo]);
                con = DriverManager.getConnection(urls[dNo]);
                
                System.out.println("* Testing with " + drivers[dNo] );

                doStuff();

                con.close();

            } catch (Exception e) {
                System.out.println(e.toString());
            }

        }

    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Main m = new Main();
        m.startServer();
        m.doBothDrivers();
        m.shutdownServer();
    }
}

Reply via email to