By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,983 Members | 1,627 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,983 IT Pros & Developers. It's quick & easy.

Sun Java System Application Server help..

jeffbroodwar
100+
P: 118
i'm currently working on a project about webservices. i tried to create an ordinary service that inserts data to the database. here's the code :

================================================== =

// ADD PRODUCT
public java.lang.String AddProduct(String description, int rprice) throws java.rmi.RemoteException
{

ResultSet rs;
String cmd;

try
{
cmd = "Select * from tblproduct";
rs=stmt.executeQuery(cmd);
rs.moveToInsertRow();
rs.updateString("description", description);
rs.updateInt("rprice", rprice);
rs.insertRow();

return "Successful";

}
// IF ERROR OCCURS CATCH HERE. EX: SQL ERROR FROM TRY BLOCK ABOVE //
catch(SQLException e1)
{

lastErrorMessage = "Database error occured : " + e1.getMessage();
return lastErrorMessage;
}

// IF DATABASE CONNECTION PROBLEM OCCURS CATCH THEN RETURN VALUE //
catch(Exception e)
{
lastErrorMessage = e.getMessage();
return lastErrorMessage;
}

}

==================================================
i've isolated the database connection to a different method..... please review the code.. actually if you will look at the code you won't see any error.... even if you test it, it works fine. the problem triggers when more than 1 client access the webservice. it throws an exception (null pointer exception) i think this problem is related to threading in the server / server settings. i'm using Sun Java System Application Server 9 update1 netbeans 5.5 and mysql 5.0.... please help me... any suggestions will be much appreciated.. thank you...
Mar 2 '07 #1
Share this Question
Share on Google+
2 Replies


10K+
P: 13,264
i'm currently working on a project about webservices. i tried to create an ordinary service that inserts data to the database. here's the code :

================================================== =

// ADD PRODUCT
public java.lang.String AddProduct(String description, int rprice) throws java.rmi.RemoteException
{

ResultSet rs;
String cmd;

try
{
cmd = "Select * from tblproduct";
rs=stmt.executeQuery(cmd);
rs.moveToInsertRow();
rs.updateString("description", description);
rs.updateInt("rprice", rprice);
rs.insertRow();

return "Successful";

}
// IF ERROR OCCURS CATCH HERE. EX: SQL ERROR FROM TRY BLOCK ABOVE //
catch(SQLException e1)
{

lastErrorMessage = "Database error occured : " + e1.getMessage();
return lastErrorMessage;
}

// IF DATABASE CONNECTION PROBLEM OCCURS CATCH THEN RETURN VALUE //
catch(Exception e)
{
lastErrorMessage = e.getMessage();
return lastErrorMessage;
}

}

==================================================
i've isolated the database connection to a different method..... please review the code.. actually if you will look at the code you won't see any error.... even if you test it, it works fine. the problem triggers when more than 1 client access the webservice. it throws an exception (null pointer exception) i think this problem is related to threading in the server / server settings. i'm using Sun Java System Application Server 9 update1 netbeans 5.5 and mysql 5.0.... please help me... any suggestions will be much appreciated.. thank you...
Is this code in a servlet?
Mar 2 '07 #2

jeffbroodwar
100+
P: 118
no...i think it has something to do with the connector settings in the sun java application admin... you have there a connector settings. under it are 3 sub categories : connector resources, connector connection pools, admin object resources..... anyway it's just a wild guess, still not sure if these settings will solve my problem. any ideas? i'm using sun java application server 8.2 and mysql 5.0 thanx again... :-)
Mar 5 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.