Topic: sql语句在jsp中的写法

  Print this page

1.sql语句在jsp中的写法 Copy to clipboard
Posted by: cenqin8899
Posted on: 2006-10-28 11:10

<=,>=这些在jsp页面中总是被看成是<=的等值,该怎么样写啊??
求救!

以下是我的部分代码:
大家看一下我的Condi这样写错在哪里??

String Condi="score <="+xuefenmax+"AND"+"score>="+xuefenmin;
String condition="SELECT * FROM student where"+Condi;
out.println(Condi+", "+condition); // 输出出错!!!
try{
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet rs=stmt.executeQuery(condition);

2.Re:sql语句在jsp中的写法 [Re: cenqin8899] Copy to clipboard
Posted by: byzddhz
Posted on: 2006-11-01 16:12

似乎还有一个问题。。where后面还要加一个空格吧?

3.Re:sql语句在jsp中的写法 [Re: cenqin8899] Copy to clipboard
Posted by:
Posted on: 2006-11-01 23:17

为什么不用PreparedStatement
String condition = "select * from student where score <= ? and score>=?";
Connection conn= DriverManager.getConnection(url,user,password);
PreparedStatement ps=conn.PreparedStatement(condition);
ps.setInt(1,xuefenmax);
ps.setInt(2,xuefenmin);
ResultSet rs=ps.executeQuery();


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923