您所在的位置:首页--IT中心--存储过程的常见问题
存储过程的常见问题
2006年7月9日18:27
字号

一个名为 INSERT_JAVASP 的示例存储过程

1   //The simplest JAVA SP
2   import java.sql.*;
3
4   public class INSERT_JAVASP
5   {
6     public static void iNSERT_JAVASP  (String input) throws SQLException,
Exception
7     {
8       int errorCode;

10      try
11      {
12        // get caller's connection to the database
13   Connection con = DriverManager.getConnection("jdbc:default:connection");
14    
15        String query = "INSERT INTO CWYLAW.StoreData (c) VALUES (?)";
16
17        PreparedStatement pstmt = con.prepareStatement(query);
18        pstmt.setString(1, input);
19        pstmt.executeUpdate();
20 
21      }  
22      catch (SQLException sqle)
23      {
24        errorCode = sqle.getErrorCode();
25        throw new SQLException( errorCode + " FAILED" );
26      }
27    }
28  }

相关连接