Java call stored procedure code

zhaozj2021-02-16  72

Import java.sql. *;

class callstore {public static void main (String [] args) {try {String driverStr = "com.microsoft.jdbc.sqlserver.SQLServerDriver"; Class.forName (driverStr) .newInstance (); Connection conn = DriverManager.getConnection ( " JDBC: Microsoft: SQLServer: //61.28.18.53: 1433; DatabaseName = Soutecinfosale "," sa "," soutec "); callablestatement st = conn.prepareCall (" {call adduser (?,?)} "); //// PreparedStatement st = conn.prepareCall ( "update SMS_Admin set PersonName = where PersonID = 'honeymoon'?"); // PreparedStatement st = conn.prepareCall ( "{call test}"); // Statement st = conn.createStatement () St.setString (1, "sssssssss"); st.setstring (2, "honey"); // st.setstring (3, "honey"); // st.setstring (4, "000"); / / String SQL = "{CALL Adduser (?,?)}"; // resultset = st.executeQuery (SQL); INT i = st.executeUpdate (); //rs.next (); //system.out .println (rs.getstring (5)); //rs.next (); // system.out.println (rs.getstring (5));} catch (sqlexception se) {system.out.println (SE. Getmes sage ()); se.printStackTrace ();} catch (ClassNotFoundException cnf) {System.out.println (cnf.getMessage ()); cnf.printStackTrace ();} catch (InstantiationException ite) {System.out.println ( ITE.GetMessage (); item (} catch (lylegalaccessexception}) {system.out.println (Iae.getMessage (); IAE.PrintStackTrace ();}

}

转载请注明原文地址:https://www.9cbs.com/read-14991.html

New Post(0)