Please be aware that the SAP SQL Anywhere Forum will be shut down on August 29th, 2024 when all it's content will be migrated to the SAP Community.

Hello,

we are using SQL Anywhere and MobiLink 16.0.0.2052.

We wrote a Java based synchronization script for the prepare_download event. In our Java method we are doing some validation, which sometimes lead to Java Exception.

When this happens, we get a sync failed on the client. That is the behaviour that we would expect. However it would be more elegant to catch the exception instead and send a meaningful error message to the client and the user.

I checked the dcx side, but could not find something about forcefully letting a sync fail and sending error messages to the client. Any idea how this can be done?

Thanks and best regards, Alex

asked 25 Mar '15, 11:37

Alexander%20Ilg's gravatar image

Alexander Ilg
346272739
accept rate: 50%


The modify_error_message script is invoked only for SQL errors, so it won't get triggered for Java exceptions.

On v12 and earlier you could return a SQL string from your Java script that will raise an error and then use the modify_error_message to change that message to what you want.

Alternatively, you could create table that you log the errors to. Then you can create a separate publication that you use to download the error if a sync fails. This would work on all version of the server. Edit: This has to be done on a connection returned by ServerContext.makeConnection(), since the connection returned by DBContext.getConnection will be rolled back when the prepare_for_download script fails.

This is a feature that customers and internal users have asked for, but I haven't had time to get around to fixing it. It's something that I would like to change, but I can't make any promises as to when or which versions.

permanent link

answered 25 Mar '15, 14:04

Bill%20Somers's gravatar image

Bill Somers
1.2k820
accept rate: 40%

edited 25 Mar '15, 14:13

There is another option. You can use the modify_error_message script. See the documentation here.

permanent link

answered 25 Mar '15, 13:27

RussC_FromSAP's gravatar image

RussC_FromSAP
1.3k11030
accept rate: 18%

As Bill answered, the modify_error_message script is only invoked for SQL errors. If a Java script causes a SQL error, it causes a SQLException in the Java script, not a SQL error visible to the MobiLink server.

(25 Mar '15, 14:38) Graham Hurst

Have you had a look at the following doc topics:

Basically, you will have to set the action_code value.

permanent link

answered 25 Mar '15, 11:53

Volker%20Barth's gravatar image

Volker Barth
40.5k365556827
accept rate: 34%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×371
×84
×78

question asked: 25 Mar '15, 11:37

question was seen: 2,431 times

last updated: 25 Mar '15, 14:38