java.sql.SQLException: Illegal operation on empty result set
来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/11/13 19:44:50
java.sql.SQLException: Illegal operation on empty result set.
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
public class shujuku {
public static void main(String args[]) {
Connection conn;
conn = Conn.getCon();
try{
Statement stmt = conn.createStatement();
ResultSet sql1=stmt.executeQuery("select * from register where name='cai'");
String iping = sql1.getString("psw");
int porting=sql1.getInt("psw2");
System.out.println(iping);
System.out.println(porting);
}catch(Exception e){
e.printStackTrace();
System.out.println("怎么会有错");
}
}
}
这个怎么错了,麻烦帮我看一下,谢谢啊
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
public class shujuku {
public static void main(String args[]) {
Connection conn;
conn = Conn.getCon();
try{
Statement stmt = conn.createStatement();
ResultSet sql1=stmt.executeQuery("select * from register where name='cai'");
String iping = sql1.getString("psw");
int porting=sql1.getInt("psw2");
System.out.println(iping);
System.out.println(porting);
}catch(Exception e){
e.printStackTrace();
System.out.println("怎么会有错");
}
}
}
这个怎么错了,麻烦帮我看一下,谢谢啊
ResultSet 是个结果集.不能这样取记录的sql1.getString("psw");
需要循环历遍的.那怕结果集返回的只有一条记录
改成这样看看.
public static void main(String args[]) {
Connection conn;
conn = Conn.getCon();
try{
Statement stmt = conn.createStatement();
ResultSet sql1=stmt.executeQuery("select * from register where name='cai'");
while(sql1.next()){
String iping = sql1.getString("psw");
int porting=sql1.getInt("psw2");
System.out.println(iping);
System.out.println(porting);
}
}catch(Exception e){
e.printStackTrace();
System.out.println("怎么会有错");
}
}
需要循环历遍的.那怕结果集返回的只有一条记录
改成这样看看.
public static void main(String args[]) {
Connection conn;
conn = Conn.getCon();
try{
Statement stmt = conn.createStatement();
ResultSet sql1=stmt.executeQuery("select * from register where name='cai'");
while(sql1.next()){
String iping = sql1.getString("psw");
int porting=sql1.getInt("psw2");
System.out.println(iping);
System.out.println(porting);
}
}catch(Exception e){
e.printStackTrace();
System.out.println("怎么会有错");
}
}
java.sql.SQLException: Illegal operation on empty result set
java.sql.SQLException:Operation not allowed after ResultSet
java.sql.SQLException:Couldn't perform the operation prepare
jforum中,通过配置-完后出现这样的问题:java.sql.SQLException:Illegal mix of
java.sql.SQLException:ORA-00917:缺失逗号
java.sql.SQLException:ORA-00918:未明确定义列
java.sql.SQLException:The transaction is no longer active-st
Exception in thread "main" java.sql.SQLException:用尽的 Results
java.sql.SQLException: Parameter index out of range (1 > num
java.sql.SQLException:Column count doesn't match value count
java.sql.SQLException:Parameter index out of range (1 > numb
java.sql.SQLException: Listener refused the connection with