(AS1) - How to get MySQL error message?

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

Rashomon
Posts: 72
Joined: 11 Aug 2010, 19:48

(AS1) - How to get MySQL error message?

Postby Rashomon » 31 Aug 2011, 14:00

I have an AS1 extension. It updates the database with executeCommand and checks for success like so:

Code: Select all

var success = dbase.executeCommand(sql)

if (success) {

} else {

}

How can I get more details on the failure, though? How can I get the actual error message so I can pass the details back to the user? I tried to use a try/catch block, but try/catch is not available in AS1. It's hard to find any AS1 docs, these days, so I was hoping you guys would know.
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Postby rjgtav » 31 Aug 2011, 14:28

Hi. I think that's only possible only with a try/catch statement.

Something like:

Code: Select all

try{
    dbase.executeCommand(sql)
}catch(e){
    trace("Error while executing command: "+e)
}


Not sure if this works and can't test now
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
Rashomon
Posts: 72
Joined: 11 Aug 2010, 19:48

Postby Rashomon » 31 Aug 2011, 15:15

Yeah. That's what I tried, earlier (my reference to the "try/catch" block). Unfortunately, I kept getting errors when I started the server.

I was using "catch(e:Error)". When I use "catch(e)", the server will start. The code will also process a successful query. However, the catch never runs. I do, however, see the error message in the dump, but it's (apparently from the system, and not from the catch:

com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry 'MyValue' for key 'my_field_UNIQUE'
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Postby rjgtav » 31 Aug 2011, 16:01

Hum... it looks like then this is not possible with AS Extensions. Maybe with Java Extensions is...
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
User avatar
BigFIsh
Posts: 1698
Joined: 25 Feb 2008, 19:26
Location: New Zealand

Postby BigFIsh » 01 Sep 2011, 04:34

It's not a good idea to send the error message to the client - it just opens a door for sql injection / hack. So that's why the error is only logged in your logs.
Smartfox's forum is my daily newspaper.

Return to “Server Side Extension Development”

Who is online

Users browsing this forum: No registered users and 17 guests