当前位置: 技术问答>java相关
查询数据库出错!!
来源: 互联网 发布时间:2017-04-20
本文导语: 我在执行一个程序时: 在servlet中执行数据库查询操作 aDBAccess.initConn(); String strsql=""; strsql="select Up_Filename,Up_Filetype,Up_Filecontent from SYS.H_Upload "; strsql=strsql + " where Up_Flowid="+ Integer.parseInt(strflowid) +" and Up_Prjid='...
我在执行一个程序时:
在servlet中执行数据库查询操作
aDBAccess.initConn();
String strsql="";
strsql="select Up_Filename,Up_Filetype,Up_Filecontent from SYS.H_Upload ";
strsql=strsql + " where Up_Flowid="+ Integer.parseInt(strflowid) +" and Up_Prjid='" + strprjid.trim() + "' and Up_prjflieid=" + Integer.parseInt(strprjfileid);
System.out.println(strsql);
rs=aDBAccess.runSelect1(strsql);
System.out.println("aaa");
运行时,在aaa之前报错,错误为:java.sql.SQLException:general error
操作数据库部分为:
ublic ResultSet runSelect1(String strSQL) {
ResultSet result = null;
java.sql.Statement sqlStatement = null;
try {
sqlStatement = conn.createStatement();
// sqlStatement = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
result = sqlStatement.executeQuery(strSQL);
} catch (Exception e) {
System.out.println(e);
result = null;
}
return result;
}
请大虾指点迷津!!
在servlet中执行数据库查询操作
aDBAccess.initConn();
String strsql="";
strsql="select Up_Filename,Up_Filetype,Up_Filecontent from SYS.H_Upload ";
strsql=strsql + " where Up_Flowid="+ Integer.parseInt(strflowid) +" and Up_Prjid='" + strprjid.trim() + "' and Up_prjflieid=" + Integer.parseInt(strprjfileid);
System.out.println(strsql);
rs=aDBAccess.runSelect1(strsql);
System.out.println("aaa");
运行时,在aaa之前报错,错误为:java.sql.SQLException:general error
操作数据库部分为:
ublic ResultSet runSelect1(String strSQL) {
ResultSet result = null;
java.sql.Statement sqlStatement = null;
try {
sqlStatement = conn.createStatement();
// sqlStatement = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
result = sqlStatement.executeQuery(strSQL);
} catch (Exception e) {
System.out.println(e);
result = null;
}
return result;
}
请大虾指点迷津!!
|
可能是SQL语句出错,
简化SQL语句,然后一步步往上加.
简化SQL语句,然后一步步往上加.
|
up
|
连接数据库问题.