package kissJava.sql;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Types;
public class SQLUtils {
String url = "jdbc:mysql://127.0.0.1:3306/userInfo";
String userName = "root";
String password = "zhui007";
public Connection getConnection() {
Connection con=null;
try{
DriverManager.registerDriver(new com.mysql.jdbc.Driver());
con = DriverManager.getConnection(url, this.userName, this.password);
}catch(SQLException sw){
}
return con;
}
public void testProc(){
Connection conn = getConnection();
CallableStatement stmt = null;
try{
stmt = conn.prepareCall("{call mappingProc(?)}");
stmt.registerOutParameter(1, Types.INTEGER);
stmt.execute();
int i= stmt.getInt(1);
System.out.println("count = " + i);
}catch(Exception e){
System.out.println("hahad = "+e.toString());
}finally{
try {
stmt.close();
conn.close();
}catch (Exception ex) {
System.out.println("ex : "+ ex.getMessage());
}
}
}
public static void main(String[] args) {
new SQLUtils().testProc();
}
}