You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Nguyen Xuan Son <ya...@gmail.com> on 2009/12/08 06:59:58 UTC

SQL ExcuteQuery

dear all
I've written
Connection conn = null;
PreparedStatement pstmtname = null;
pstmtname = conn.prepareStatement(sql);
 sql = "UPDATE tbl_content_admin_accounts SET CA_PASSWORD = ? WHERE ROW_ID =
" + UserID;
pstmtname.setString(1, "123456");
pstmtname.executeQuery();

there is no error appear but nothing is changed in the database
do you have any suggestion?
thank you very much

-- 
=======================================================================
Ritsumeikan University, Asia JinZai Project
Master of Information Science
Nguyen Xuan Son

Add       : Japan, Shiga-Ken, Kusatsu-Shi, Kasayama 3choume 1-18 ShiteiHaimu
Rien, Room 103
Tel/Fax  : 81-(0)90-3976 2246
Email    : nr0003xx@ed.ritsumei.ac.jp
Mobile   : 81-(0)90-3976 2246          URL  : http://www.ritsumei.jp
=======================================================================

Re: SQL ExcuteQuery

Posted by mu...@aol.com.
 Your trouble is here:


pstmtname = conn.prepareStatement(sql);
 sql = "UPDATE tbl_content_admin_accounts SET CA_PASSWORD = ? WHERE ROW_ID =
" + UserID;


 
When you call prepareStatement(sql) the sql string is sent to the database which "prepares" it (essentially does all the steps neccessary before execution). You then change the sql string and the database knows nothing about it.

Change it so that the sql = line comes before the conn.prepareStatement line.

 

Chris
 

 

-----Original Message-----
From: Nguyen Xuan Son <ya...@gmail.com>
To: Struts Users Mailing List <us...@struts.apache.org>
Sent: Tue, Dec 8, 2009 12:59 am
Subject: SQL ExcuteQuery


dear all
I've written
Connection conn = null;
PreparedStatement pstmtname = null;
pstmtname = conn.prepareStatement(sql);
 sql = "UPDATE tbl_content_admin_accounts SET CA_PASSWORD = ? WHERE ROW_ID =
" + UserID;
pstmtname.setString(1, "123456");
pstmtname.executeQuery();

there is no error appear but nothing is changed in the database
do you have any suggestion?
thank you very much

-- 
=======================================================================
Ritsumeikan University, Asia JinZai Project
Master of Information Science
Nguyen Xuan Son

Add       : Japan, Shiga-Ken, Kusatsu-Shi, Kasayama 3choume 1-18 ShiteiHaimu
Rien, Room 103
Tel/Fax  : 81-(0)90-3976 2246
Email    : nr0003xx@ed.ritsumei.ac.jp
Mobile   : 81-(0)90-3976 2246          URL  : http://www.ritsumei.jp
=======================================================================

 

Re: SQL ExcuteQuery

Posted by Saeed Iqbal <sa...@gmail.com>.
I dont see you make database connection like this for example.

conn = DriverManager.getConnection

("jdbc:mysql://your_host:3306/dbName","dbUser","dbPass");



On Tue, Dec 8, 2009 at 10:59 AM, Nguyen Xuan Son <ya...@gmail.com> wrote:

> dear all
> I've written
> Connection conn = null;
> PreparedStatement pstmtname = null;
> pstmtname = conn.prepareStatement(sql);
>  sql = "UPDATE tbl_content_admin_accounts SET CA_PASSWORD = ? WHERE ROW_ID
> =
> " + UserID;
> pstmtname.setString(1, "123456");
> pstmtname.executeQuery();
>
> there is no error appear but nothing is changed in the database
> do you have any suggestion?
> thank you very much
>
> --
> =======================================================================
> Ritsumeikan University, Asia JinZai Project
> Master of Information Science
> Nguyen Xuan Son
>
> Add       : Japan, Shiga-Ken, Kusatsu-Shi, Kasayama 3choume 1-18
> ShiteiHaimu
> Rien, Room 103
> Tel/Fax  : 81-(0)90-3976 2246
> Email    : nr0003xx@ed.ritsumei.ac.jp
> Mobile   : 81-(0)90-3976 2246          URL  : http://www.ritsumei.jp
> =======================================================================
>



-- 
Saeed Iqbal
Independant Consultant
J2EE - Application Architect / Developer

Re: SQL ExcuteQuery

Posted by Sushim Saini <su...@gmail.com>.
sorry use executeUpdate

On Tue, Dec 8, 2009 at 11:53, Nguyen Xuan Son <ya...@gmail.com> wrote:

> dear singgh
> I've tried to user the excuteUpdate but the errors appear
> detail is
>
> java.sql.SQLException: Can not issue executeUpdate() for SELECTs
>        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
>        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
>        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926)
>        at
> com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2320)
>        at
> com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2280)
>        at
> com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2265)
>
> do you have any suggestion?
>
> thanks you very much
>
>
> 2009/12/8 Avlesh Singh <av...@gmail.com>
>
> > Use #executeUpdate instead.
> >
> > Cheers
> > Avlesh
> >
> > On Tue, Dec 8, 2009 at 11:37 AM, Nguyen Xuan Son <ya...@gmail.com>
> > wrote:
> >
> > > sorry saini but i dont see any different from your answer
> > > thank you
> > >
> > > 2009/12/8 Sushim Saini <su...@gmail.com>
> > >
> > > > hi Nguyen Xuan Son
> > > > use
> > > > pstmtname.executeQuery() instead of pstmtname.executeQuery();
> > > >
> > > > On Tue, Dec 8, 2009 at 11:29, Nguyen Xuan Son <ya...@gmail.com>
> > wrote:
> > > >
> > > > > dear all
> > > > > I've written
> > > > > Connection conn = null;
> > > > > PreparedStatement pstmtname = null;
> > > > > pstmtname = conn.prepareStatement(sql);
> > > > >  sql = "UPDATE tbl_content_admin_accounts SET CA_PASSWORD = ? WHERE
> > > > ROW_ID
> > > > > =
> > > > > " + UserID;
> > > > > pstmtname.setString(1, "123456");
> > > > > pstmtname.executeQuery();
> > > > >
> > > > > there is no error appear but nothing is changed in the database
> > > > > do you have any suggestion?
> > > > > thank you very much
> > > > >
> > > > > --
> > > > >
> > =======================================================================
> > > > > Ritsumeikan University, Asia JinZai Project
> > > > > Master of Information Science
> > > > > Nguyen Xuan Son
> > > > >
> > > > > Add       : Japan, Shiga-Ken, Kusatsu-Shi, Kasayama 3choume 1-18
> > > > > ShiteiHaimu
> > > > > Rien, Room 103
> > > > > Tel/Fax  : 81-(0)90-3976 2246
> > > > > Email    : nr0003xx@ed.ritsumei.ac.jp
> > > > > Mobile   : 81-(0)90-3976 2246          URL  :
> http://www.ritsumei.jp
> > > > >
> > =======================================================================
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > --
> > > > Sushim Saini
> > > >
> > >
> > >
> > >
> > > --
> > > =======================================================================
> > > Ritsumeikan University, Asia JinZai Project
> > > Master of Information Science
> > > Nguyen Xuan Son
> > >
> > > Add       : Japan, Shiga-Ken, Kusatsu-Shi, Kasayama 3choume 1-18
> > > ShiteiHaimu
> > > Rien, Room 103
> > > Tel/Fax  : 81-(0)90-3976 2246
> > > Email    : nr0003xx@ed.ritsumei.ac.jp
> > > Mobile   : 81-(0)90-3976 2246          URL  : http://www.ritsumei.jp
> > > =======================================================================
> > >
> >
>
>
>
> --
> =======================================================================
> Ritsumeikan University, Asia JinZai Project
> Master of Information Science
> Nguyen Xuan Son
>
> Add       : Japan, Shiga-Ken, Kusatsu-Shi, Kasayama 3choume 1-18
> ShiteiHaimu
> Rien, Room 103
> Tel/Fax  : 81-(0)90-3976 2246
> Email    : nr0003xx@ed.ritsumei.ac.jp
> Mobile   : 81-(0)90-3976 2246          URL  : http://www.ritsumei.jp
> =======================================================================
>



-- 
--
Sushim Saini

Re: SQL ExcuteQuery

Posted by Nguyen Xuan Son <ya...@gmail.com>.
dear singgh
I've tried to user the excuteUpdate but the errors appear
detail is

java.sql.SQLException: Can not issue executeUpdate() for SELECTs
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926)
	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2320)
	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2280)
	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2265)

do you have any suggestion?

thanks you very much


2009/12/8 Avlesh Singh <av...@gmail.com>

> Use #executeUpdate instead.
>
> Cheers
> Avlesh
>
> On Tue, Dec 8, 2009 at 11:37 AM, Nguyen Xuan Son <ya...@gmail.com>
> wrote:
>
> > sorry saini but i dont see any different from your answer
> > thank you
> >
> > 2009/12/8 Sushim Saini <su...@gmail.com>
> >
> > > hi Nguyen Xuan Son
> > > use
> > > pstmtname.executeQuery() instead of pstmtname.executeQuery();
> > >
> > > On Tue, Dec 8, 2009 at 11:29, Nguyen Xuan Son <ya...@gmail.com>
> wrote:
> > >
> > > > dear all
> > > > I've written
> > > > Connection conn = null;
> > > > PreparedStatement pstmtname = null;
> > > > pstmtname = conn.prepareStatement(sql);
> > > >  sql = "UPDATE tbl_content_admin_accounts SET CA_PASSWORD = ? WHERE
> > > ROW_ID
> > > > =
> > > > " + UserID;
> > > > pstmtname.setString(1, "123456");
> > > > pstmtname.executeQuery();
> > > >
> > > > there is no error appear but nothing is changed in the database
> > > > do you have any suggestion?
> > > > thank you very much
> > > >
> > > > --
> > > >
> =======================================================================
> > > > Ritsumeikan University, Asia JinZai Project
> > > > Master of Information Science
> > > > Nguyen Xuan Son
> > > >
> > > > Add       : Japan, Shiga-Ken, Kusatsu-Shi, Kasayama 3choume 1-18
> > > > ShiteiHaimu
> > > > Rien, Room 103
> > > > Tel/Fax  : 81-(0)90-3976 2246
> > > > Email    : nr0003xx@ed.ritsumei.ac.jp
> > > > Mobile   : 81-(0)90-3976 2246          URL  : http://www.ritsumei.jp
> > > >
> =======================================================================
> > > >
> > >
> > >
> > >
> > > --
> > > --
> > > Sushim Saini
> > >
> >
> >
> >
> > --
> > =======================================================================
> > Ritsumeikan University, Asia JinZai Project
> > Master of Information Science
> > Nguyen Xuan Son
> >
> > Add       : Japan, Shiga-Ken, Kusatsu-Shi, Kasayama 3choume 1-18
> > ShiteiHaimu
> > Rien, Room 103
> > Tel/Fax  : 81-(0)90-3976 2246
> > Email    : nr0003xx@ed.ritsumei.ac.jp
> > Mobile   : 81-(0)90-3976 2246          URL  : http://www.ritsumei.jp
> > =======================================================================
> >
>



-- 
=======================================================================
Ritsumeikan University, Asia JinZai Project
Master of Information Science
Nguyen Xuan Son

Add       : Japan, Shiga-Ken, Kusatsu-Shi, Kasayama 3choume 1-18 ShiteiHaimu
Rien, Room 103
Tel/Fax  : 81-(0)90-3976 2246
Email    : nr0003xx@ed.ritsumei.ac.jp
Mobile   : 81-(0)90-3976 2246          URL  : http://www.ritsumei.jp
=======================================================================

Re: SQL ExcuteQuery

Posted by Avlesh Singh <av...@gmail.com>.
Use #executeUpdate instead.

Cheers
Avlesh

On Tue, Dec 8, 2009 at 11:37 AM, Nguyen Xuan Son <ya...@gmail.com> wrote:

> sorry saini but i dont see any different from your answer
> thank you
>
> 2009/12/8 Sushim Saini <su...@gmail.com>
>
> > hi Nguyen Xuan Son
> > use
> > pstmtname.executeQuery() instead of pstmtname.executeQuery();
> >
> > On Tue, Dec 8, 2009 at 11:29, Nguyen Xuan Son <ya...@gmail.com> wrote:
> >
> > > dear all
> > > I've written
> > > Connection conn = null;
> > > PreparedStatement pstmtname = null;
> > > pstmtname = conn.prepareStatement(sql);
> > >  sql = "UPDATE tbl_content_admin_accounts SET CA_PASSWORD = ? WHERE
> > ROW_ID
> > > =
> > > " + UserID;
> > > pstmtname.setString(1, "123456");
> > > pstmtname.executeQuery();
> > >
> > > there is no error appear but nothing is changed in the database
> > > do you have any suggestion?
> > > thank you very much
> > >
> > > --
> > > =======================================================================
> > > Ritsumeikan University, Asia JinZai Project
> > > Master of Information Science
> > > Nguyen Xuan Son
> > >
> > > Add       : Japan, Shiga-Ken, Kusatsu-Shi, Kasayama 3choume 1-18
> > > ShiteiHaimu
> > > Rien, Room 103
> > > Tel/Fax  : 81-(0)90-3976 2246
> > > Email    : nr0003xx@ed.ritsumei.ac.jp
> > > Mobile   : 81-(0)90-3976 2246          URL  : http://www.ritsumei.jp
> > > =======================================================================
> > >
> >
> >
> >
> > --
> > --
> > Sushim Saini
> >
>
>
>
> --
> =======================================================================
> Ritsumeikan University, Asia JinZai Project
> Master of Information Science
> Nguyen Xuan Son
>
> Add       : Japan, Shiga-Ken, Kusatsu-Shi, Kasayama 3choume 1-18
> ShiteiHaimu
> Rien, Room 103
> Tel/Fax  : 81-(0)90-3976 2246
> Email    : nr0003xx@ed.ritsumei.ac.jp
> Mobile   : 81-(0)90-3976 2246          URL  : http://www.ritsumei.jp
> =======================================================================
>

Re: SQL ExcuteQuery

Posted by Nguyen Xuan Son <ya...@gmail.com>.
sorry saini but i dont see any different from your answer
thank you

2009/12/8 Sushim Saini <su...@gmail.com>

> hi Nguyen Xuan Son
> use
> pstmtname.executeQuery() instead of pstmtname.executeQuery();
>
> On Tue, Dec 8, 2009 at 11:29, Nguyen Xuan Son <ya...@gmail.com> wrote:
>
> > dear all
> > I've written
> > Connection conn = null;
> > PreparedStatement pstmtname = null;
> > pstmtname = conn.prepareStatement(sql);
> >  sql = "UPDATE tbl_content_admin_accounts SET CA_PASSWORD = ? WHERE
> ROW_ID
> > =
> > " + UserID;
> > pstmtname.setString(1, "123456");
> > pstmtname.executeQuery();
> >
> > there is no error appear but nothing is changed in the database
> > do you have any suggestion?
> > thank you very much
> >
> > --
> > =======================================================================
> > Ritsumeikan University, Asia JinZai Project
> > Master of Information Science
> > Nguyen Xuan Son
> >
> > Add       : Japan, Shiga-Ken, Kusatsu-Shi, Kasayama 3choume 1-18
> > ShiteiHaimu
> > Rien, Room 103
> > Tel/Fax  : 81-(0)90-3976 2246
> > Email    : nr0003xx@ed.ritsumei.ac.jp
> > Mobile   : 81-(0)90-3976 2246          URL  : http://www.ritsumei.jp
> > =======================================================================
> >
>
>
>
> --
> --
> Sushim Saini
>



-- 
=======================================================================
Ritsumeikan University, Asia JinZai Project
Master of Information Science
Nguyen Xuan Son

Add       : Japan, Shiga-Ken, Kusatsu-Shi, Kasayama 3choume 1-18 ShiteiHaimu
Rien, Room 103
Tel/Fax  : 81-(0)90-3976 2246
Email    : nr0003xx@ed.ritsumei.ac.jp
Mobile   : 81-(0)90-3976 2246          URL  : http://www.ritsumei.jp
=======================================================================

Re: SQL ExcuteQuery

Posted by Sushim Saini <su...@gmail.com>.
hi Nguyen Xuan Son
use
pstmtname.executeQuery() instead of pstmtname.executeQuery();

On Tue, Dec 8, 2009 at 11:29, Nguyen Xuan Son <ya...@gmail.com> wrote:

> dear all
> I've written
> Connection conn = null;
> PreparedStatement pstmtname = null;
> pstmtname = conn.prepareStatement(sql);
>  sql = "UPDATE tbl_content_admin_accounts SET CA_PASSWORD = ? WHERE ROW_ID
> =
> " + UserID;
> pstmtname.setString(1, "123456");
> pstmtname.executeQuery();
>
> there is no error appear but nothing is changed in the database
> do you have any suggestion?
> thank you very much
>
> --
> =======================================================================
> Ritsumeikan University, Asia JinZai Project
> Master of Information Science
> Nguyen Xuan Son
>
> Add       : Japan, Shiga-Ken, Kusatsu-Shi, Kasayama 3choume 1-18
> ShiteiHaimu
> Rien, Room 103
> Tel/Fax  : 81-(0)90-3976 2246
> Email    : nr0003xx@ed.ritsumei.ac.jp
> Mobile   : 81-(0)90-3976 2246          URL  : http://www.ritsumei.jp
> =======================================================================
>



-- 
--
Sushim Saini