你是说数据库么?好像昨天刚刚有人问过。搜索一下。使用SQLException

解决方案 »

  1.   

    是的呀,我用事务写了一段代码,帮我修改一下吧
    这里的错误太多了<%@ page contentType="text/html;charset=gb2312"%> 
    <%@ page import="java.sql.*"%>
     <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>db</title>
    </head><html> 
    <body>
    <%Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance(); 
    String url="jdbc:microsoft:sqlserver://192.168.10.3:1433;DatabaseName=QQ"; 
    String user="sa"; 
    String password="123"; 
    Connection con= DriverManager.getConnection(url,user,password); 
      con.setAutoCommit(false); 
      PreparedStatement updateSales=con.prepareStatement("UPDATE notice SET n_content=? WHERE n_subject=?"); 
      updateSales.setString(1,"今天的天气特别好"); 
      updateSales.setString(2,"通知"); 
      updateSales.executeUpdate(); 
      PreparedStatement updateTotal=con.prepareStatement("UPDATE notice SET n_createdate =n_createdate- ? WHERE n_content= ?"); 
      updateTotal.setString(1,"20"); 
      updateTotal.setString(2,"发资金"); 
      updateTotal.executeUpdate(); 
      con.commit(); 
      con.setAutoCommit(true); 
    con.close(); 
    %>
    </p>
    </body> 
    </html>