If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > JAVA > executeUpdate not executed

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-16-07, 06:32
minnysikka minnysikka is offline
Registered User
 
Join Date: May 2007
Posts: 5
executeUpdate not executed

Hi,
I m using mysql and Jboss 4.0.4 GA. I m trying to insert the data in the database. but executeUpdate command is not executed. It doesn't shhows anything in the log file.it prints the values in the server's log but not executing this command (I mean not showing values in database)and doesn't shows any error in the
Please help me

Thanks
Reply With Quote
  #2 (permalink)  
Old 05-16-07, 07:52
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,407
Did you commit your changes?
Are you catching and processing any Exceptions that might be thrown by executeUpdate()
Reply With Quote
  #3 (permalink)  
Old 05-17-07, 00:03
minnysikka minnysikka is offline
Registered User
 
Join Date: May 2007
Posts: 5
it doesn't show any exception. I send u the code that i m using. it doesn't show any error in the log but not displaying data in the database


package com.pdws.action;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import java.util.ArrayList;
import javax.sql.DataSource;
import com.pdws.vo.*;
import javax.servlet.http.HttpSession;

public class DepartmentAction extends Action{
public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception{
//DbConnect dbobj=new DbConnect();
DataSource ds = this.getDataSource(request);
DepartmentVO deptvo=new DepartmentVO();
HttpSession session=request.getSession(true);
String dcode=request.getParameter("dCode");
System.out.println(dcode);
String dname=request.getParameter("dName");
System.out.println(dname);
boolean flag = false;
deptvo.setDeptcode(dcode);
deptvo.setDeptname(dname);
flag = addInfo(dcode,dname, ds);

return mapping.findForward("show");
}
public boolean addInfo(String dcode, String dname, DataSource ds) throws Exception {
Connection con = null;
Statement stmt_get = null;
Statement stmt_set = null;
PreparedStatement psmt = null;
ResultSet rs = null;
try {
con = ds.getConnection();
stmt_get = con.createStatement();
stmt_set = con.createStatement();
System.out.println("database connected 1");
String sqString = null;
try {
psmt = con.prepareStatement("insert into dept values(?,?)");
psmt.setString(1, dcode);
psmt.setString(2, dname);
System.out.println(dcode);
System.out.println("database connected 2");
psmt.executeUpdate();
System.out.println("database connected 3");
} catch (Exception e) {
System.out.println("Error in sql command 4");
}
} catch (Exception uaexist) {
uaexist.printStackTrace();
} finally {
if (rs != null)
rs.close();
if (stmt_get != null)
stmt_get.close();
if (stmt_set != null)
stmt_set.close();
if (con != null)
con.close();
System.out.println("database connected 5");
}
return true;

}
}


Thanks for ur reply
Reply With Quote
  #4 (permalink)  
Old 05-17-07, 02:44
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,407
Read my first question: where is your commit?
(and you should use code tags the next time you post code)
Reply With Quote
  #5 (permalink)  
Old 06-04-07, 02:28
modsiw modsiw is offline
Registered User
 
Join Date: Jun 2007
Posts: 2
Easiest solution, but manual commits are probably better.


PreparedStatement psmt = null;
ResultSet rs = null;
try {
con = ds.getConnection();

con.setAutoCommit(true);

stmt_get = con.createStatement();
stmt_set = con.createStatement();
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On