error executing multiple insert statements

2011-06-16 Thread Lothar Krenzien
Hello,

I'd like to execute multiple insert statements over JDBC at once, but can't get 
it work ;(

Here a small demo:

...

insert into POSITIONTEMPLATE
(ID,VERSION,NAME,PRINT)
values 
(NEXT VALUE FOR unique_id,0,'abc',1);
 
insert into POSITIONTEMPLATE
(ID,VERSION,NAME,PRINT)
values 
(NEXT VALUE FOR unique_id,0,'efg',0);


If I execute every statement at once it works fine but if I execute all 
statements at once I always get the following error:

Encountered ; at line 4 column 9.

I know that it means that there is a problem with the ; sign - but that can't 
be right or ?
Derby 10.8.1.2

Thank you


Re: error executing multiple insert statements

2011-06-16 Thread Peter Ondruška
Run this in ij. That is for running SQL scripts. Or execute each
statement (without ;) separately.

On Thu, Jun 16, 2011 at 8:03 PM, Lothar Krenzien lkrenz...@web.de wrote:
 Hello,

 I'd like to execute multiple insert statements over JDBC at once, but can't 
 get it work ;(

 Here a small demo:

 ...

 insert into POSITIONTEMPLATE
 (ID,VERSION,NAME,PRINT)
 values
 (NEXT VALUE FOR unique_id,0,'abc',1);

 insert into POSITIONTEMPLATE
 (ID,VERSION,NAME,PRINT)
 values
 (NEXT VALUE FOR unique_id,0,'efg',0);


 If I execute every statement at once it works fine but if I execute all 
 statements at once I always get the following error:

 Encountered ; at line 4 column 9.

 I know that it means that there is a problem with the ; sign - but that 
 can't be right or ?
 Derby 10.8.1.2

 Thank you



Re: error executing multiple insert statements

2011-06-16 Thread Lothar Krenzien
But shouldn't it works with JDBC too ?



Re: error executing multiple insert statements

2011-06-16 Thread Bryan Pendleton

On 06/16/2011 11:38 AM, Lothar Krenzien wrote:

But shouldn't it works with JDBC too ?



Perhaps you are looking for the batch facility of JDBC, as in the
addBatch/executeBatch methods on java.sql.Statement:

http://download.oracle.com/javase/1.4.2/docs/api/java/sql/Statement.html#executeBatch()

thanks,

bryan



RE: Disappearing service.properties file

2011-06-16 Thread Brett Mason
Thanks,

Logged as DERBY-5283.

Cheers,
Brett.

-Original Message-
From: Dag H. Wanvik [mailto:dag.wan...@oracle.com] 
Sent: Wednesday, 8 June 2011 00:05
To: Derby Discussion
Subject: Re: Disappearing service.properties file

Brett Mason b.ma...@adinstruments.com writes:

 It does seem that Cases 1  2 are fairly easy to reproduce by terminating
 the Java process while it is updating service.properties. I've included
some
 sample code which will trigger the problem quite reliably when it is
 terminated on the following environments:

 Windows 7 64-bit, Sun 32-bit JRE 1.6u20, Derby 10.6.1.0
 Windows 7 64-bit, Sun 32-bit JDK 1.6u25, Derby 10.8.1.2
 Debian Linux 5.0, 32-bit, Sun JRE 1.6u20, Derby 10.6.1.0 (running within
 Virtual Box)

 Is this issue worth reporting as a bug?

 Are there other scenarios where the file might be updated as part of
 normal database usage? Particularly for regular INSERT/UPDATE/DELETE
 statements, but also maintenance procedures such as SYSCS_BACKUP_DATABASE,
 SYSCS_CHECK_TABLE, SYSCS_COMPRESS_TABLE, SYSCS_UPDATE_STATISTICS.

Please file a JIRA issue for this so we can discuss it in the community
with a view to improving the way we handle these transactional propery
settings. I don't think INSERT/UPDATE/DELETE are subject to this
scenario, but backup/restore may be. As for statistics, I don't think so
from my preliminary investigation, but I am not 100% sure yet.

Dag


 Thanks,
 Brett.



 import java.sql.*;
 import org.apache.derby.jdbc.*;

 public class DerbyLogArchiveModeTest {
 
 public static void main(String[] args) {
 final EmbeddedDataSource ds = new EmbeddedDataSource();
 ds.setDatabaseName(derbyTest);
 ds.setCreateDatabase(create);

 try {
 final Connection conn = ds.getConnection();

 try {
 final Statement stmt = conn.createStatement();

 try {
 while (true) {
 stmt.execute(call
 SYSCS_UTIL.SYSCS_DISABLE_LOG_ARCHIVE_MODE(1));
 }
 } finally {
 stmt.close();
 }
 } finally {
 conn.close();
 }
 } catch (SQLException e) {
 e.printStackTrace();
 }
 }
 }