| Author |
Regarding - returning user defined object array from bottom-up webservice .
|
het jain
Greenhorn
Joined: Oct 22, 2012
Posts: 2
|
|
When i try to return user defined object array and run webservice tests client , i get following error.
Exception: org.xml.sax.SAXParseException: Premature end of file. Message: ; nested exception is: org.xml.sax.SAXParseException: Premature end of file.
I tried debugging the code , it works all fine but when "return user[]" statement comes it throws this error.
i have created 3 java files user.java, service.java,databaseconnection.java
user.java
public class user
{
public String username;
public String password;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
databaseconnection.java
public user[] getUserdetailsString() {
user[] UserList = null;
try {
String query = "select * from Customer";
ResultSet rc = stmt.executeQuery(query);
if (rc != null) {
rc.last();
int size = rc.getRow();
UserList = new user[size];
int i = 0;
rc.beforeFirst();
System.out.println(size);
while (rc.next()) {
user user = new user();
System.out.println(i);
u.username = rc.getString("username");
u.password = rc.getString("password");
System.out.println(u.username + u.password);
// u[i] = u1;
// uarraylistdatabase.add(u1);
UserList[i] = user;
i++;
}
}
} catch (SQLException sql) {
sql.printStackTrace();
}
return UserList;
service.java
public user[] getString()
{
user[] ulist = null;
System.out.println("getDetailString");
ulist = db.getUserdetailsString();
return ulist;
}
I am stuck with same problem from 4-5 days
please help me
|
 |
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12265
|
|
If this was my problem I would use the SAXParseException methods getLineNumber and getColumnNumber to find out where it thinks it hit eof.
Bill
|
Java Resources at www.wbrogden.com
|
 |
het jain
Greenhorn
Joined: Oct 22, 2012
Posts: 2
|
|
Thanks Bill for quick reply.
I am all new to this webservices thing so didnt got idea to do this.
but when i am trying to add try and catch block for saxparserexception.
catch(SAXParseException e)
{
e.getLineNumber();
e.getColumnNumber();
e.printStackTrace();
}
It is giving be error "Unreachable catch block for SAXParseException. This exception is never thrown from the try statement body"
Thanks
Het
|
 |
 |
|
|
subject: Regarding - returning user defined object array from bottom-up webservice .
|
|
|