import java.net.URL; import java.sql.*; class bug_procedure_columns { public static void main (String args[]) throws Exception { String url = "jdbc:mysql://localhost/bug_procedure_columns" ; Connection con = null; DatabaseMetaData dma = null; try { Class.forName ("com.mysql.jdbc.Driver"); DriverManager.setLoginTimeout(15); con = DriverManager.getConnection ( url, "root", ""); Statement stmt = con.createStatement(); stmt.executeUpdate("DROP PROCEDURE IF EXISTS `bug_procedure_columns`;"); stmt.executeUpdate("CREATE PROCEDURE `bug_procedure_columns`(" + "p1_in INTEGER, p2_in CHAR(20)," + "OUT p3_out INTEGER, OUT p4_out CHAR(11))\n" + "BEGIN\n" + "SET p3_out = 144;\n" + "SET p4_out = 'CHARACTER11';\n" + "SELECT p3_out, p4_out;\n" + "END"); dma = con.getMetaData (); System.out.println("\nCalling getProcedureColumns(null, null, \"%\", null)"); ResultSet rs = dma.getProcedureColumns(null, null, "%", null); ResultSetMetaData rsmd = rs.getMetaData(); System.out.println("\nOutputting procedure columns info:"); for (int j = 1; j < 14; j++) { String column_name = rsmd.getColumnName(j); int column_size = rsmd.getColumnDisplaySize(j); System.out.println("getColumnName("+j+") =" + column_name); System.out.println("getColumnDisplaySize("+j+") =" + column_size); System.out.println(""); } boolean more = rs.next(); while (more) { System.out.println("\nPROCEDURE_CAT is: "+rs.getString(1)); System.out.println("PROCEDURE_SCHEM is: "+rs.getString(2)); System.out.println("PROCEDURE_NAME is: "+rs.getString(3)); System.out.println("COLUMN_NAME is: "+rs.getString(4)); System.out.println("COLUMN_TYPE is: "+rs.getString(5)); System.out.println("DATA_TYPE is: "+rs.getString(6)); more = rs.next(); } rs.close(); con.close(); } catch (SQLException ex) { System.out.println ("Message: " + ex.getMessage ()); ex.printStackTrace (); } } // end of main }