怎么用servlet对oracle进行增删改查???请赐教
加载驱动2创建连接
public static Connection getConn() throws SQLException,
ClassNotFoundException {
Class.forName("com.mysql.jdbc.Driver");//1
return DriverManager
.getConnection(
"jdbc:mysql://localhost:3306/bookstore?useUnicode=true&characterEncoding=utf-8",
"root", "password");//2
}
3执行语句
String sql = "select authorise from user where username=? and password = ?";
pst=con.prepareStatement(sql);
pst.setString(1, name);
pst.setString(2, password);
rs = pst.executeQuery();//查询用这条
String sql="update book set bookname=?,price=? where id=?";
pst=con.prepareStatement(sql);
pst.setString(1, book.getBookname());
pst.setFloat(2, book.getPrice());
pst.setInt(3,book.getId());
count=pst.executeUpdate();//增删改用这条
4得到结果
while(rs.next()!=null){}
5关闭连接
if (rs != null) {
rs.close();
}
if (pst != null) {
pst.close();
}
if (con != null) {
con.close();
}
是对oracle的操作而不是mysql,具体代码能写一下吗?谢谢
不需要jsp跳转吗?经理要求不用jsp 可我没试过