Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem updating a record in Sybase.

Status
Not open for further replies.

adrivim

Programmer
May 25, 2006
1
0
0
CA
Hi,

I am trying to update a record in Sybase, from my Struts Action class. Here is the code:
>>>>>>>...
Code:
String clientId = myForm.getClient().trim();
String bookAlg = myForm.getBookingAlgo().trim();
String commAlg = myForm.getCommisionAlgo().trim();
String sql = "UPDATE fix..FIX_Clients SET TickettingAlg=?, CommissionAlg=? WHERE FIXClientID=?";

//prepare connect to DB
ServletContext context = servlet.getServletContext();
DataSource dataSource = (DataSource)context.getAttribute(Globals.DATA_SOURCE_KEY);
Connection conn = null;
PreparedStatement stmt = null;;
int rows = 0;

try
{
 conn = dataSource.getConnection();
 if(conn == null){
   target = Constants.ERROR;
   errors.add("database", new ActionMessage("error.db.update.failed"));
   return (mapping.findForward(target));
 }
 stmt = conn.prepareStatement(sql);
 stmt.setString(1,bookAlg);
 stmt.setString(2,commAlg);
 stmt.setInt(3,Integer.parseInt(clientId));
 rows = stmt.executeUpdate();
 System.out.println("Query execution returned: " + rows);
}
catch(SQLException e)
..............

In my struts-config.xml I have this entry for the dataSource
..............
Code:
<!-- ========== Data Sources Definitions ============ -->
<data-sources>
 <data-source type="org.apache.commons.dbcp.BasicDataSource">
  	<set-property property="driverClassName" value="com.sybase.jdbc3.jdbc.SybDriver" />
  	<set-property property="url" value="jdbc:sybase:Tds:myDB:myPort/WNLWNSCK?autoReconnect=true" />  		
  	<set-property property="username" value="name" />
  	<set-property property="password" value="password" />
  	<set-property property="maxCount" value="5" />
  	<set-property property="minCount" value="1" /> 
    	<set-property property="defaultAutoCommit" value="false" />
    	<set-property property="defaultReadOnly" value="false" />
  </data-source>
</data-sources>
..............

The SELECT works fine, and the UPDATE returns a "1" for the row updated, but when I check the DB the record is actually not updated. The login name and password has DB Admin privileges.
I thank you in advance for your help and appreciate any feedback!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top