Re: An I/O error occured while sending to the backend

Re: An I/O error occured while sending to the backend

am 27.06.2007 03:20:09 von Mutua K

Any help?

Am reading a couple of values from a txt file and store them in a table. The
first line of the txt file is read well and saved. When the program reads
the second line, it displays the errors listed down.

Here is a method am using:

public boolean addUser(
String ID,
String Password,
String lastName,
String firstName)
throws SQLException, ClassNotFoundException, IOException {
conn = Connect.getConnection();
while (in.ready()) {
String line = in.readLine();
st = new StringTokenizer(line);
while (st.hasMoreTokens()){
myID = st.nextToken();
myPassword = st.nextToken();
mylastName = st.nextToken();
myfirstName = st.nextToken();

ID = myID;
Password = myPassword;
lastName = mylastName;
firstName = myfirstName;

String sql = "INSERT INTO supervisor " +
"(superv_id, superv_pass, superv_lastname,
superv_firstname)" +
"VALUES (?,?,?,?)";
prep = conn.prepareStatement(sql);
prep.setString(1, ID);
prep.setString(2, Password);
prep.setString(3, lastName);
prep.setString(4, firstName);
prep.executeUpdate();
conn.close();
}
}
return true;
}


Error:

Exception in thread "main" org.postgresql.util.PSQLException: An I/O error
occured while sending to the backend.
Exception: java.io.IOException: Stream closed
Stack Trace:
java.io.IOException: Stream closed
at sun.nio.cs.StreamEncoder.ensureOpen(StreamEncoder.java:38)
at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:151)
at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:213 )
at org.postgresql.core.PGStream.flush(PGStream.java:507)
at
org.postgresql.core.v3.QueryExecutorImpl.sendSync(QueryExecu torImpl.java:675)
at
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecut orImpl.java:190)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(Abstract Jdbc2Statement.java:452)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags (AbstractJdbc2Statement.java:351)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(Ab stractJdbc2Statement.java:305)
at prototype.PopulatingDB.addUser(PopulatingDB.java:68)
at prototype.PopulatingDB.(PopulatingDB.java:29)
at prototype.PopulatingDB.main(PopulatingDB.java:77)
End of Stack Trace

at
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecut orImpl.java:217)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(Abstract Jdbc2Statement.java:452)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags (AbstractJdbc2Statement.java:351)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(Ab stractJdbc2Statement.java:305)
at prototype.PopulatingDB.addUser(PopulatingDB.java:68)
at prototype.PopulatingDB.(PopulatingDB.java:29)
at prototype.PopulatingDB.main(PopulatingDB.java:77)
Java Result: 1

____________________________________________________________ _____
Tell MSN about your most memorable emails! http://www.emailbritain.co.uk/


---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

http://www.postgresql.org/about/donate