callable-statement

Parameter number 2 is not an OUT parameter

泄露秘密 提交于 2019-12-02 10:10:46
String sqlString = "{CALL MyStoredProcedure(?,?)}"; CallableStatement sqlStm = connection.prepareCall(sqlString); sqlStm.setString(1, username); sqlStm.registerOutParameter(2, Types.DECIMAL, 0); // <---- ERROR sqlStm.execute(); This is my error stacktrace: java.sql.SQLException: Parameter number 2 is not an OUT parameter at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:982) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:927) at com.mysql

How in JDBC can you call a stored procedure when only setting some parameters

☆樱花仙子☆ 提交于 2019-11-30 22:33:19
What is the best way to make a call to a stored procedure using JDBC if you only want to set some of the parameters? If I was just using SQL, I could set the paramerers by name in the SQL to call the sproc. E.g. if I have a stored procedure with nine parameters and I wanted to set parameters 1,2 and 9, leaving the rest to their default values, I can run this SQL: exec my_stored_procedure @parameter_1 = "ONE", @parameter_2 = "TWO", @parameter_9 = "NINE" Using JDBC (Specifically jConnect 6.0), it seems that when using a CallableStatement, you have to set the parameters by their integer index,

Cannot retrieve the value I desired to Select using Stored Procedure

拟墨画扇 提交于 2019-11-26 18:35:59
问题 I'm trying to find a record. Which let me choose to find a existing record in my database using Stored Procedure. When I tried to search a existing data it doesn't give me the value that I want. When I hit the search button it's not printing the value to the textfield. CODE private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { String searchSection = Section_SearchSection_Textfield.getText(); String searchSection_Name = Section_SectionName_TextField.getText(); int sectionID =