PL/SQL包过程代码:
create or replace package body cridit_pkg is
procedure add_bill(
cardno bill.cardno%type,
btype bill.btype%type,
shopno bill.shopno%type,
tono bill.tono%type,
ip bill.ip%type,
fromno bill.fromno%type,
amount bill.amount%type,
bdate bill.bdate%type)
is
begin
insert into bill values(gb_billno.nextval,cardno,btype,shopno,tono,ip,fromno,amount,bdate);
end;
end cridit_pkg; JAVA代码
String cardno = request.getParameter("cardno");
String btype = request.getParameter("btype");
String shopno = request.getParameter("shopno");
String tono = request.getParameter("tono");
String ip1= request.getParameter("ip1");
String ip2= request.getParameter("ip2");
String ip3= request.getParameter("ip3");
String ip4= request.getParameter("ip4");
String ip = ip1+"."+ip2+"."+ip3+"."+ip4;
String fromno = request.getParameter("fromno");
String amount = request.getParameter("amount");
String date = request.getParameter("date1")+"-"+
request.getParameter("date2")+"-"+
request.getParameter("date3");
String bdate ="to_date('"+date+"','yyyy-mm-dd')"; CriditcardDAO criditcardao = new CriditcardDAOJdbc();
result = criditcardao.insertBill(cardno,btype,shopno,tono,ip,fromno,amount,bdate); //具体方法:
public int insertBill(String cardno, String btype,
String shopno, String tono, String ip, String fromno,
String amount, String bdate) {
// TODO Auto-generated method stub
int result=0;
String sql="{ call cridit_pkg.add_bill(?,?,?,?,?,?,?,?)}";
String param[]={cardno,btype,shopno,tono,ip,fromno,amount,bdate};
result=db.update(sql, param);
return result;
}
//测试
cardno:9527
btype:商场消费
amount:1000
date1:2009
date2:1
date3:1
//提交结果
java.sql.SQLException: ORA-01858: 在要求输入数字处找到非数字字符
ORA-06512: 在 line 1
Query: { call cridit_pkg.add_bill(?,?,?,?,?,?,?,?)} Parameters: [9527, 商场消费, 9527, null, null, null, 1000, to_date('2009-1-01','yyyy-mm-dd')]
//当不输入日期时(没有to_date('2009-1-01','yyyy-mm-dd')时),结果正确.
//请教各位大侠,我该怎么改。
create or replace package body cridit_pkg is
procedure add_bill(
cardno bill.cardno%type,
btype bill.btype%type,
shopno bill.shopno%type,
tono bill.tono%type,
ip bill.ip%type,
fromno bill.fromno%type,
amount bill.amount%type,
bdate bill.bdate%type)
is
begin
insert into bill values(gb_billno.nextval,cardno,btype,shopno,tono,ip,fromno,amount,bdate);
end;
end cridit_pkg; JAVA代码
String cardno = request.getParameter("cardno");
String btype = request.getParameter("btype");
String shopno = request.getParameter("shopno");
String tono = request.getParameter("tono");
String ip1= request.getParameter("ip1");
String ip2= request.getParameter("ip2");
String ip3= request.getParameter("ip3");
String ip4= request.getParameter("ip4");
String ip = ip1+"."+ip2+"."+ip3+"."+ip4;
String fromno = request.getParameter("fromno");
String amount = request.getParameter("amount");
String date = request.getParameter("date1")+"-"+
request.getParameter("date2")+"-"+
request.getParameter("date3");
String bdate ="to_date('"+date+"','yyyy-mm-dd')"; CriditcardDAO criditcardao = new CriditcardDAOJdbc();
result = criditcardao.insertBill(cardno,btype,shopno,tono,ip,fromno,amount,bdate); //具体方法:
public int insertBill(String cardno, String btype,
String shopno, String tono, String ip, String fromno,
String amount, String bdate) {
// TODO Auto-generated method stub
int result=0;
String sql="{ call cridit_pkg.add_bill(?,?,?,?,?,?,?,?)}";
String param[]={cardno,btype,shopno,tono,ip,fromno,amount,bdate};
result=db.update(sql, param);
return result;
}
//测试
cardno:9527
btype:商场消费
amount:1000
date1:2009
date2:1
date3:1
//提交结果
java.sql.SQLException: ORA-01858: 在要求输入数字处找到非数字字符
ORA-06512: 在 line 1
Query: { call cridit_pkg.add_bill(?,?,?,?,?,?,?,?)} Parameters: [9527, 商场消费, 9527, null, null, null, 1000, to_date('2009-1-01','yyyy-mm-dd')]
//当不输入日期时(没有to_date('2009-1-01','yyyy-mm-dd')时),结果正确.
//请教各位大侠,我该怎么改。
解决方案 »
- 求一本好的适合初学者的jsp的书,内容最好是比较新的,像那些内容比较过时的就不要推荐了,谢谢。
- java web工业实时监控
- 关于datapicker控件获得焦点问题.(在线等)
- 帮我看一下这段代码为什么得不到结果
- Myeclipse+Hibernate时驱动JTDS问题和ODBC问题
- 域名访问问题
- J2EE还要学什么?
- 请教java如何写一个Webservice的客户端?
- 高分求救--关于在jbuilder9下调试程序
- 移除部署项目struts出现这个异常NoClassDefFoundError,求解释
- 关于Spring的读取applicationContext的问题
- spring2.5的@Component注解为什么离开IDE就失效了呢???
如果是varchar或varchar2或char的话当然输入日期就有问题了。