Java. SQL. sqlexception: the stream has been disabled.

Source: Internet
Author: User

The database fields are as follows:
Id integer
Username varchar2 (50) y
Sender varchar2 (50) y
Message long y
Sendtime varchar2 (20) y
Isread varchar2 (1) y

Getall method of Dao Layer
Public list <smspo> getall ()
{
String listsql = "select * from SMS ";
List <smspo> listsms = new arraylist <smspo> ();
Preparedstatement PS = dbbase. Prepare (connection, listsql );
Try {
Resultset rsw.ps.exe cutequery ();
While (Rs. Next ())
{
Smspo = new smspo ();
Smspo. setid (Rs. getint (1 ));
Smspo. setusername (Rs. getstring ("username "));
Smspo. setsender (Rs. getstring ("sender "));
Smspo. setsendtime (Rs. getstring ("sendtime "));
Smspo. setmessage (Rs. getstring ("message "));
Smspo. setisread (Rs. getboolean ("isread "));
Listsms. Add (smspo );
}
} Catch (sqlexception e ){
// Todo auto-generated Catch Block
E. printstacktrace ();
} Finally
{
Dbbase. Close (PS );
Dbbase. Close (connection );
}
Return listsms;
}

Test the main function:
Public static void main (string [] ARGs ){
Smsservice = new smsservice ();
List <smspo> List = smsservice. getall ();
Iterator <smspo> iterator = List. iterator ();
While (iterator. hasnext ())
{
Smspo = iterator. Next ();
System. Out. println (smspo. GetUserName ());
}
}
When running, an error occurs:
Java. SQL. sqlexception: the stream has been disabled.
At oracle. JDBC. Driver. databaseerror. throwsqlexception (databaseerror. Java: 111)
At oracle. JDBC. Driver. databaseerror. throwsqlexception (databaseerror. Java: 145)
At oracle. JDBC. Driver. databaseerror. throwsqlexception (databaseerror. Java: 207)
At oracle. JDBC. Driver. longaccessor. getbytes (longaccessor. Java: 150)
At oracle. JDBC. Driver. longaccessor. getstring (longaccessor. Java: 192)
At oracle. JDBC. Driver. t4clongaccessor. getstring (t4clongaccessor. Java: 421)
At oracle. JDBC. Driver. oracleresultsetimpl. getstring (oracleresultsetimpl. Java: 396)
At oracle. JDBC. Driver. oracleresultset. getstring (oracleresultset. Java: 1514)
At com.yy180.doc man. Dao. smsdao. getall (smsdao. Java: 33)
At com.yy180.doc man. Service. smsservice. getall (smsservice. Java: 19)
At com. yy180.all. testall. Main (testall. Java: 12)

When I modify the sequence of the DaO Layer Code:
While (Rs. Next ())
{
Smspo = new smspo ();
Smspo. setid (Rs. getint (1 ));
Smspo. setusername (Rs. getstring ("username "));
Smspo. setsender (Rs. getstring ("sender "));
Smspo. setmessage (Rs. getstring ("message "));
Smspo. setsendtime (Rs. getstring ("sendtime "));
Smspo. setisread (Rs. getboolean ("isread "));
Listsms. Add (smspo );
}

Run it ..
The reason may be that the stream reading from the database is sequential. When the database is not read in order, an error occurs,

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.