473,385 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

inline SQL PL over JDBC

Hi there,

Is it possible to use inline SQL PL over JDBC? If so, which statement
type is required and what syntax does the inline SQL PL take? A
CallableStatement, for example, need to be enclosed within curly
braces: eg:

{CALL some_procedure()}

Cheers

Michael

Feb 20 '07 #1
5 3500
Kenevel wrote:
Hi there,

Is it possible to use inline SQL PL over JDBC? If so, which statement
type is required and what syntax does the inline SQL PL take? A
CallableStatement, for example, need to be enclosed within curly
braces: eg:
Not clear I understand your question...
Ar eyou asking whether you can submit a BEGIN ATOMIC ... END from JDBC?
The answer to that AFAIk is yes. Use the same API you use for e.g. UPDATE.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Feb 21 '07 #2
Kenevel wrote:
Hi there,

Is it possible to use inline SQL PL over JDBC? If so, which statement
type is required and what syntax does the inline SQL PL take? A
CallableStatement, for example, need to be enclosed within curly
braces: eg:

{CALL some_procedure()}
That is not correct. You can call a stored procedure through JDBC simply
this way:

CALL some_procedure(...)

Have a look at the samples, specifically
sqllib/samples/java/jdbc/SpClient.java.

--
Knut Stolze
DB2 z/OS Utilities Development
IBM Germany
Feb 21 '07 #3
On 21 Feb, 12:49, Serge Rielau <srie...@ca.ibm.comwrote:
>
Not clear I understand your question...
Are you asking whether you can submit a BEGIN ATOMIC ... END from JDBC?
The answer to that AFAIk is yes. Use the same API you use for e.g. UPDATE.
Hi Serge,

Yes: I am asking whether I can submit a BEGIN ATOMIC ... END over
JDBC. There are advantages from an application-packaging point-of-view
if you can keep this sort of logic within the Java application itself,
rather than installing the same logic in the DB as a stored procedure
or function - both from a deployment and a rollback perspective.

My problem is that the simple examples I've tried have invariably all
complained about the syntax - so I wondered whether anyone knew the
exact Java statement type (eg: Statement, CallableStatement,
PreparedStatement) to use, and also the associated syntax (hence the
quick example in my first post of how the syntax for a
CallableStatement varies from a Statement or PreparedStatement).

Cheers

Michael

Feb 22 '07 #4
I may be dumb, but I know people ... ;-)
Try this:

Statement stmt = con.createStatement();
stmt.execute( "begin atomic" +
" insert into t1 values (1);" +
" insert into t1 values (2);" +
"end" );

PreparedStatement pstmt = con.prepareStatement(
"begin atomic" +
" insert into t1 values (?);" +
" insert into t1 values (?);" +
"end" );

pstmt.setInt( 1, 3 );
pstmt.setInt( 2, 4 );
pstmt.execute();

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Feb 22 '07 #5
Kenevel wrote:
My problem is that the simple examples I've tried have invariably all
complained about the syntax - so I wondered whether anyone knew the
exact Java statement type (eg: Statement, CallableStatement,
PreparedStatement) to use, and also the associated syntax (hence the
quick example in my first post of how the syntax for a
CallableStatement varies from a Statement or PreparedStatement).
What exactly are those statements and what are the errors you got from DB2?
As Serge said, compound statements are regular SQL statements and you can
execute them as usual through JDBC. So I would suspect a problem with your
application.

--
Knut Stolze
DB2 z/OS Utilities Development
IBM Germany
Feb 22 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: JShurmatz | last post by:
If anyone can shed some light on this problem I would greatly appreciate it. I am unsuccessfully trying to use a database connnection retrieved from a pool configured using Java System Web...
0
by: Nils Valentin | last post by:
Hi MySQL Fans ;-), Is it possible that the 3.08 series allows to connect to 4.0.14 versions but not to the 4.1 alpha-versions ? I get belows error when tryig to connect from DbVisualizer which...
0
by: Robert Mazur | last post by:
MySQL 5.0 alpha (binary install) on Solaris 9 -or- RedHat 8.0 mysql-connector-java-3.0.8-stable ----------------------- Is there something different going on with JDBC and the alpha version...
0
by: Bing | last post by:
Hi, I am configuring the same DB2 v8.1 JDBC universal driver (db2jcc.jar and db2jcc_license_cisuz.jar) from DB2 SP5 fix pack under WSAD 5.1.x environment and WebSphere application Server 5.0.2...
1
by: Praveen | last post by:
Hi, I have installed WebSphere Portal on AIX and connected to DB2 on a remote machine, Getting the followin errors when trying to get the values from database thru applications installed on...
1
by: rpm45tech | last post by:
Hi everyone. I'm deveolping in Java with DB2 running on Win XP and everything was working ok but then I installed Vista Ultimate and the application stopped working. This is the exception showed: ...
2
by: bevis | last post by:
I'm new to sql server and mysql but this seems like it should be a pretty straight forward jdbc connection. But I have spent almost 2 days just trying to get a jdbc connection. Please help if you...
3
by: Anoop | last post by:
Is it true that there are no type 4 jdbc drivers to connect to a DB2 server v7.1? The DB2 server is hosted on ACF2 (OS/390). We would be connecting from windows and solaris boxes. If it is true,...
0
by: Jim Kennedy | last post by:
ALL DDL does a commit. Hence Drop Table movies; issues a commit. True you don't issue a commit and the driver does not issue a commit, but the server does for all DDL. That is probably where...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.