海信家电”换帅 “ 高玉玲接替代慧忠出任新任董事长
2024-11-22
<%@ page import="
javax.naming.*, java.util.*, java.sql.*, weblogic.common.* " %> <% String name String product; long quantity; name=request.getParameter("name"); product=request.getParameter("product"); quantity=request.getParameter("quantity"); /*(1)*/ savebuy(); %> <%! public void savebuy() { /*进行数据库操作,把数据保存到表中*/ try { Properties props = new Properties(); props.put("user","scott"); props.put("password","tiger"); props.put("server","DEMO"); Driver myDriver = (Driver) iver").newInstance(); conn = myDriver.connect("jdbc:weblogic:oracle", props); stmt = conn.createStatement(); String inssql = "insert into buy(empid, name, dept) values (?, ?, ?,?)"; stmt = conn.prepareStatement(inssql); stmt.setString(1, name); stmt.setString(2, procuct); stmt.setInt(3, quantity); stmt.execute(); } catch (Exception e) { System.out.println("SQLException was thrown: " + e.getMessage()); } finally //close connections and { try { if(stmt != null) stmt.close(); if(conn != null) conn.close(); } catch (SQLException sqle) { System.out.println("SQLException was thrown: " + sqle.getMessage()); } } } %> |
评论 {{userinfo.comments}}
{{child.content}}
{{question.question}}
提交