这个代码。我已经提到了查询停止的位置。控制台也没有错误。可能是什么问题呢。我正在使用postgres数据库。从jsp servlet获取数据并通过servlet作为字符串传递给dao。但由于我的数据库格式不同,我想将变量转换为各自的类型。但我首先要检查插入查询是否适用于虚拟数据。似乎每件事情都运行良好,但代码流停在提到的位置,并且我的数据库中也没有插入数据。
public void doInsert(Connection conn, String i, String nam,String indate, String amont, String tx, String tot,String closd, String shipvia, String not) throws Exception {
ResultSet rs = null;
ResultSet rs1 = null;
Statement st=null;
Statement st1=null;
// TODO Auto-generated method stub
try{
/* String in=indate;
String reverse = new StringBuffer(in).reverse().toString();
System.out.println(reverse);
System.out.println(reverse);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-dd");
String dateInString = indate;
Date date = sdf.parse(dateInString);
System.out.println(date);*/
/*String it=i;
String n=nam;
String in=indate;
String a=amont;
String t=tx;
String tota=tot;
String closed=closd;
String ship_via=shipvia;
String note=not;
to_date("+date+",'YYYY-MM-DD')*/
System.out.println("came above sql");
/*to_date("+date+",'YYYY-MM-DD')*/
String sql="insert into invheader(id,invdate,client_id,amount,tax,total,closed,ship_via,note) values(100001,to_date('1963-09-01', 'YYYY-MM-DD'),100001,100.00,20.00,120.00,TRUE,'tnt','note 1')";
//"insert into invheader(id,invdate,client_id,amount,tax,total,closed,ship_via,note) values('',to_date('1963-09-01', 'YYYY-MM-DD'),"+i+","+amont+","+tx+","+tot+","+closd+","+shipvia+","+not+")";
System.out.println("after 1st query");
String sql1="insert into clients(client_id,name) values("+i+","+nam+")";
System.out.println("after 2nd query");
st =conn.createStatement();
st1 =conn.createStatement();
//Statement stmt1 = conn.createStatement();//connection to statement
System.out.println("above execute"); //<======= code stops here
rs=st.executeQuery(sql);
System.out.println("above execute1");
rs1=st1.executeQuery(sql1);
System.out.println("inserted dao");
}catch(Exception e){
e.printStackTrace();
throw e;
}
// TODO Auto-generated method stub
}
请帮帮我。可能是什么原因?