⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 parametermetadatajdbc30.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
      cs.close();	   System.out.println("Behaviour of meta data and out params after re-compile");      cs = con.prepareCall("CALL dummyint(?,?,?,?)");	  cs.registerOutParameter(3,Types.INTEGER);      cs.registerOutParameter(4,Types.INTEGER);      cs.setInt(1,1);      cs.setInt(2,1);	  cs.setInt(4,4);	  dumpParameterMetaData(cs.getParameterMetaData());	  cs.execute();      System.out.println("DUMMYINT alias returned " + cs.getInt(4));      s.executeUpdate("drop procedure dummyint");      s.executeUpdate("create procedure dummyint(in a integer, in b integer, out c integer, inout d integer) language java external name 'org.apache.derbyTesting.functionTests.tests.jdbcapi.parameterMetaDataJdbc30.dummyint2' parameter style java");      cs.execute();      dumpParameterMetaData(cs.getParameterMetaData());      cs.setInt(4, 6);      // following is incorrect sequence, should execute first, then get       // but leaving it in as an additional negative test. see beetle 5886       System.out.println("DUMMYINT alias returned " + cs.getInt(4));      cs.execute();      System.out.println("DUMMYINT alias returned " + cs.getInt(4));      cs.close();      // temp disable for network server      if (!isDerbyNet) {      // Java procedure support	  System.out.println("ParameterMetaData for Java procedures with INTEGER parameters");	  s.execute("CREATE PROCEDURE PMDI(IN pmdI_1 INTEGER, IN pmdI_2 INTEGER, INOUT pmdI_3 INTEGER, OUT pmdI_4 INTEGER) language java parameter style java external name 'org.apache.derbyTesting.functionTests.tests.jdbcapi.parameterMetaDataJdbc30.dummyint'");      cs = con.prepareCall("CALL PMDI(?, ?, ?, ?)");	  dumpParameterMetaData(cs.getParameterMetaData());	  cs.close();	  s.execute("DROP PROCEDURE PMDI");	  System.out.println("ParameterMetaData for Java procedures with CHAR parameters");	  s.execute("CREATE PROCEDURE PMDC(IN pmdI_1 CHAR(10), IN pmdI_2 VARCHAR(25), INOUT pmdI_3 CHAR(19), OUT pmdI_4 VARCHAR(32)) language java parameter style java external name 'org.apache.derbyTesting.functionTests.tests.jdbcapi.parameterMetaDataJdbc30.dummyString'");      cs = con.prepareCall("CALL PMDC(?, ?, ?, ?)");	  dumpParameterMetaData(cs.getParameterMetaData());	  cs.close();	  s.execute("DROP PROCEDURE PMDC");	  System.out.println("ParameterMetaData for Java procedures with DECIMAL parameters");	  s.execute("CREATE PROCEDURE PMDD(IN pmdI_1 DECIMAL(5,3), IN pmdI_2 DECIMAL(4,2), INOUT pmdI_3 DECIMAL(9,0), OUT pmdI_4 DECIMAL(10,2)) language java parameter style java external name 'org.apache.derbyTesting.functionTests.tests.jdbcapi.parameterMetaDataJdbc30.dummyDecimal'");      cs = con.prepareCall("CALL PMDD(?, ?, ?, ?)");	  dumpParameterMetaData(cs.getParameterMetaData());	  cs.close();	  System.out.println("ParameterMetaData for Java procedures with some literal parameters");      cs = con.prepareCall("CALL PMDD(32.4, ?, ?, ?)");	  dumpParameterMetaData(cs.getParameterMetaData());	  cs.close();      cs = con.prepareCall("CALL PMDD(32.4, 47.9, ?, ?)");	  dumpParameterMetaData(cs.getParameterMetaData());	  cs.close();      cs = con.prepareCall("CALL PMDD(?, 38.2, ?, ?)");	  dumpParameterMetaData(cs.getParameterMetaData());	  cs.close();	  s.execute("DROP PROCEDURE PMDD");      }     }	 catch (SQLException e) {	 dumpSQLExceptions(e);	 }	 catch (Throwable e) {		System.out.println("FAIL -- unexpected exception:");		e.printStackTrace(System.out);	 }	 System.out.println("Test parameterMetaDataJdbc30 finished");	}	static void dumpParameterMetaData(ParameterMetaData paramMetaData) throws SQLException {		int numParam = paramMetaData.getParameterCount();		for (int i=1; i<=numParam; i++) {			try {			System.out.println("Parameter number : " + i);			System.out.println("parameter isNullable " + parameterIsNullableInStringForm(paramMetaData.isNullable(i)));			System.out.println("parameter isSigned " + paramMetaData.isSigned(i));			System.out.println("parameter getPrecision " + paramMetaData.getPrecision(i));			System.out.println("parameter getScale " + paramMetaData.getScale(i));			System.out.println("parameter getParameterType " + paramMetaData.getParameterType(i));			System.out.println("parameter getParameterTypeName " + paramMetaData.getParameterTypeName(i));			System.out.println("parameter getParameterClassName " + paramMetaData.getParameterClassName(i));			System.out.println("parameter getParameterMode " + parameterModeInStringForm(paramMetaData.getParameterMode(i)));			} catch (Throwable t) {				System.out.println(t.toString());				t.printStackTrace(System.out);			}		}	}	//negative test	static void dumpParameterMetaDataNegative(ParameterMetaData paramMetaData) throws SQLException {		int numParam = paramMetaData.getParameterCount();		try {			System.out.println("parameter isNullable " + paramMetaData.isNullable(-1));		} catch (SQLException e) {			dumpExpectedSQLExceptions(e);		}		try {			System.out.println("parameter isNullable " + paramMetaData.isNullable(0));		} catch (SQLException e) {			dumpExpectedSQLExceptions(e);		}		try {			System.out.println("parameter isNullable " + paramMetaData.isNullable(numParam+1));		} catch (SQLException e) {			dumpExpectedSQLExceptions(e);		}	}	static private void dumpExpectedSQLExceptions (SQLException se) {		System.out.println("PASS -- expected exception");		while (se != null)		{			System.out.println("SQLSTATE("+se.getSQLState()+"): "+ "SQL Exception: " + se.getMessage());			se = se.getNextException();        }    }	//print the parameter mode in human readable form	static String parameterModeInStringForm(int mode){		if (mode ==  ParameterMetaData.parameterModeIn)				  return("PARAMETER_MODE_IN");		else if (mode ==  ParameterMetaData.parameterModeInOut )				  return("PARAMETER_MODE_IN_OUT");		else if (mode ==  ParameterMetaData.parameterModeOut)				  return("PARAMETER_MODE_OUT");		else if (mode ==  ParameterMetaData.parameterModeUnknown)				  return("PARAMETER_MODE_UNKNOWN");		else				  return("ERROR: donot recognize this parameter mode");  }	//print the parameter isNullable value in human readable form	static String parameterIsNullableInStringForm(int nullabilityValue){		if (nullabilityValue ==  ParameterMetaData.parameterNoNulls)				  return("PARAMETER_NO_NULLS");		else if (nullabilityValue ==  ParameterMetaData.parameterNullable)				  return("PARAMETER_NULLABLE");		else if (nullabilityValue ==  ParameterMetaData.parameterNullableUnknown)				  return("PARAMETER_NULLABLE_UNKNOWN");		else				  return("ERROR: donot recognize this parameter isNullable() value");  }	//Set up the test by creating the table used by the rest of the test.	static void setUpTest(Statement s)					throws SQLException {		/* Create a table */		s.execute("create table t ( "+				  /* 1 */ "c char(5), "+				  /* 2 */ "iNoNull int not null, "+				  /* 3 */ "i int, "+				  /* 4 */ "de decimal, "+				  /* 5 */ "d date)");	}	//A really simple method to test callable statement	public static void dummyint (int in_param, int in_param2, int[] in_param3, int[] in_param4)    								   throws SQLException {		in_param4[0] = 11111;	}	public static void dummyint2 (int in_param, int in_param2, int[] in_param3, int[] in_param4)    								   throws SQLException {		in_param4[0] = 22222;	}		public static void dummy_numeric_Proc (BigDecimal[] max_param,BigDecimal[] min_param)        							 throws SQLException {//	System.out.println("dummy_numeric_Proc -- all output parameters"); taking println out because it won't display in master under drda	}	public static void dummyString (String in_param, String in_param2, String[] in_param3, String[] in_param4) {	}	public static void dummyDecimal(BigDecimal in_param, BigDecimal in_param2, BigDecimal[] in_param3, BigDecimal[] in_param4) {	}		static private void dumpSQLExceptions (SQLException se) {		System.out.println("FAIL -- unexpected exception");		while (se != null) {			System.out.print("SQLSTATE("+se.getSQLState()+"):");			se.printStackTrace(System.out);			se = se.getNextException();		}	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -