?????????????????????????洢????
???????????? ???????[ 2013/7/24 10:13:25 ] ????????
???????
????????????insert??????Ч??
public static void main(String[] args) throws SQLException {
Connection conn = null;
PreparedStatement st = null;
ResultSet rs = null;
try{
conn = JdbcUtils.getConnection();
String sql = "insert into test(name) values('aaa')";
//????Statement.RETURN_GENERATED_KEYS???????????????????????????????д?? ?????????????????С?
st = conn.prepareStatement(sql??Statement.RETURN_GENERATED_KEYS);
st.executeUpdate();
//????getGeneratedKeys?????????????
rs = st.getGeneratedKeys();
if(rs.next()){
//???????
System.out.println(rs.getInt(1));
}
}finally{
JdbcUtils.release(conn?? st?? rs);
}
}
????????洢????
??????MySQL?д????洢????
delimiter $$
CREATE PROCEDURE demoSp(IN inputParamVARCHAR(255)?? INOUT inOutParam varchar(255))
BEGIN
SELECT CONCAT('zyxw---'?? inputParam) intoinOutParam??
END $$
delimiter ??
//????
public class Demo {
public static void main(String[] args) throws SQLException {
Connection conn = null;
CallableStatement st = null;
ResultSet rs = null;
try{
conn = JdbcUtils.getConnection();
//????洢????
st = conn.prepareCall("{call demoSp(????)}");
//?滻?λ??
st.setString(1?? "aaaaa");
//??????????
st.registerOutParameter(2?? Types.VARCHAR);
st.execute();
System.out.println(st.getString(2));
}finally{
JdbcUtils.release(conn?? st?? rs);
}
}
}
??????????????
????ResultSet????????????й??????????
????next()????????????
????Previous()???????????
????absolute(int row)????????????
????beforeFirst()?????resultSet????檔
????afterLast() ???????resultSet????檔
????????????????????
????afterLast()??
????Previous()??
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11