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

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);
}
}
}
...全文
10 2 点赞 打赏 收藏 举报
写回复
2 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
BillyW 2004-05-04
朋友,什么错误提示?

今天都在外面happy,csdn的人少了
  • 打赏
  • 举报
回复
bingziyu 2004-05-04
高手在哪里呀?
  • 打赏
  • 举报
回复
相关推荐
发帖
Web 开发
加入

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2004-05-04 12:27
社区公告
暂无公告