Getting an output parameter from a stored procedure : JDBC ODBC « Database SQL JDBC « Java






Getting an output parameter from a stored procedure

  
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;

public class CheckPassword {
  public static void main(String args[]) throws Exception {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection("jdbc:odbc:Customers", "user", "pwd");

    CallableStatement cs = con.prepareCall("{call CHECK_USER_NAME(?,?,?)}");
    cs.setString(1, "C");
    cs.setString(2, "V");
    cs.registerOutParameter(3, java.sql.Types.VARCHAR);
    cs.executeUpdate();
    System.out.println(cs.getString(3));
    con.close();
  }
}

   
  








Related examples in the same category

1.jdbc:odbc bridge
2.JdbcOdbc Connect
3.jdbc odbc bridge connection string
4.Simple example of JDBC-ODBC functionality
5.Using a PreparedStatement through sun.jdbc.odbc.JdbcOdbcDriver
6.Creating and using a stored procedure with sun.jdbc.odbc.JdbcOdbcDriver
7.Retrieving a ResultSet from JdbcOdbcDriver
8.Opening an updatable ResultSet
9.Using ResultSetMetaData from jdbc:odbc
10.Creating a table using JdbcOdbcDriver
11.Using INSERT with JdbcOdbcDriver
12.Using UPDATE with JdbcOdbcDriver
13.Creating and dropping indexes
14.Using DSN-less connection