大家帮帮我啊!救命啊!在线等!

bingziyu 2004-05-04 12:27:31
为什么我加上这些代码显示不出来呢?
<%@ page contentType="text/html; charset=GB18030" pageEncoding="GB18030"%>
<%@ page language="java" import="java.sql.*,java.io.*,java.util.*" %>
<jsp:useBean id="company" class="com.crm.database.databaseOperator" />
<%
String name=request.getParameter("name");
int id=Integer.parseInt(request.getParameter("id"));
String country=request.getParameter("country");
String province=request.getParameter("province");
String city=request.getParameter("city");
String youbian=request.getParameter("youbian");
String add=request.getParameter("add");
String from=request.getParameter("from");
String tel=request.getParameter("tel");
String fax=request.getParameter("fax");
String mail=request.getParameter("mail");
String mainpage=request.getParameter("mainpage");
String income=request.getParameter("income");
String staff=request.getParameter("staff");
String trade=request.getParameter("trade");
String type=request.getParameter("type");
String note=request.getParameter("note");
company.connect();
company.addCompany(name,id,country,province,city,youbian,add,tel,fax,mail,mainpage,income,staff,trade,type,from,note);
company.disconnect();
%>


这是我的bean
package com.crm.database;

import java.sql.*;
import java.util.*;
//import com.crm.database.company;
import javax.servlet.http.HttpServletRequest;

public class databaseOperator{
//public databaseOperateor() {}
String error;
Connection con;
public void connect() throws ClassNotFoundException,SQLException,Exception {
String url="jdbc:mysql://localhost/smartcrm?useUnicode=true&characterEncoding=gb2312";
String user="custom";
String pwd="custom";
Connection conn=null;
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn=DriverManager.getConnection(url,user,pwd);
}catch (ClassNotFoundException cnfe) {
error = "ClassNotFoundException: Could not locate DB driver.";
throw new ClassNotFoundException(error);
} catch (SQLException cnfe) {
error = "SQLException: Could not connect to database.";
throw new SQLException(error);
} catch (Exception e) {
error = "Exception: An unknown error occurred while connecting " +
"to database.";
throw new Exception(error);
}
}
public void disconnect() throws SQLException {
try {
if ( con != null ) {
con.close();
}
} catch (SQLException sqle) {
error = ("SQLException: Unable to close the database connection.");
throw new SQLException(error);
}
}
//增加客户
public void addCompany(String name,int id,String country,String province,String city,String youbian,
String add,String tel,String fax,String mail,String mainpage,String income,
String staff,String trade,String type,String from,String note)throws SQLException,
Exception {
if(con!=null){
try{
PreparedStatement updatecompany;
updatecompany=con.prepareStatement(
"insert into company values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);");
updatecompany.setString(1,name);
updatecompany.setInt(2,id);
updatecompany.setString(3,country);
updatecompany.setString(4,province);
updatecompany.setString(5,city);
updatecompany.setString(6,youbian);
updatecompany.setString(7,add);
updatecompany.setString(8,tel);
updatecompany.setString(9,fax);
updatecompany.setString(10,mail);
updatecompany.setString(11,mainpage);
updatecompany.setString(12,income);
updatecompany.setString(13,staff);
updatecompany.setString(14,trade);
updatecompany.setString(15,type);
updatecompany.setString(16,from);
updatecompany.setString(17,note);
updatecompany.execute();

}catch (SQLException sqle) {
error = "SQLException: update failed, possible duplicate entry";
throw new SQLException(error);
}
} else {
error = "Exception: Connection to database was lost.";
throw new Exception(error);
}
}
}
...全文
25 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
BillyW 2004-05-04
  • 打赏
  • 举报
回复
朋友,什么错误提示?

今天都在外面happy,csdn的人少了
bingziyu 2004-05-04
  • 打赏
  • 举报
回复
高手在哪里呀?

81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧