关于JSP SQL 插入语句和更新语句的问题 10
<%try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");Connectionconn=DriverManager.getC...
<%
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn=DriverManager.getConnection("jdbc:odbc:bb","lili","1234");
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
sql="INSERT INTO student VALUES(20056,'马云',81,85,67)";
stmt.executeUpdate(sql);
sql="UPDATE student SET computer=94,c=90 WHERE no=20035";
stmt.executeUpdate(sql);
rs.close();
stmt.close();
conn.close();
}
catch(ClassNotFoundException e){
out.println("驱动异常!<br>");
out.println(e.getMessage());}
catch(SQLException e){
out.println("数据库连接或SQL查询异常!<br>");
out.println(e.getMessage());}
catch(Exception e){
out.println("其他异常!<br>");
out.println(e.getMessage());}
%> 展开
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn=DriverManager.getConnection("jdbc:odbc:bb","lili","1234");
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
sql="INSERT INTO student VALUES(20056,'马云',81,85,67)";
stmt.executeUpdate(sql);
sql="UPDATE student SET computer=94,c=90 WHERE no=20035";
stmt.executeUpdate(sql);
rs.close();
stmt.close();
conn.close();
}
catch(ClassNotFoundException e){
out.println("驱动异常!<br>");
out.println(e.getMessage());}
catch(SQLException e){
out.println("数据库连接或SQL查询异常!<br>");
out.println(e.getMessage());}
catch(Exception e){
out.println("其他异常!<br>");
out.println(e.getMessage());}
%> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询