Re: Problem inserting
On 04/16/13 01:46 PM, Alejandro Rodríguez González wrote: Basically, I insert using this code: public void insertInputs(SetInput ri) throws Exception { PreparedStatement psInsert = null; IteratorInput it = ri.iterator(); while (it.hasNext()) { Input in = it.next(); Note that doing it this way defeats the purpose of using prepared statements, since you create and prepare it each time through the loop. A better (faster) way would be to move the call to prepareStatement out of the loop. But it does psInsert = conn .prepareStatement(insert into inputs(input_class,api) values (?, ?)); Where does conn come from here? Are you sure it is in autocommit mode? It needs to be since you don't call conn.commit() explicitly. Also, you're using the default schema for your table. Are you sure it is what you believe it to be? psInsert.setString(1, in.getObject()); If Constants.APIS[this.api] does not change as you iterate, it does not need to be a parameter. psInsert.setString(2, Constants.APIS[this.api]); this.logger.log(Inserting input in db: + in.getObject() + - API[ + Constants.APIS[this.api] + ]); I assume that you see this output when you run your program? psInsert.executeUpdate(); Place the close after the loop to re-use the prepared statement. psInsert.close(); } } It is supposed that in the following execution of my program, when I made the select statement to see the inputs in the database, it should give me results, but.. no results are provided. I attach you the first two executions of my program: First (database not created): http://pastebin.com/1k7R8Yup Second (database created. It is supposed that inputs table should contain data): http://pastebin.com/yzsK1q9w So.. as far as I understand, something is wrong in the insert but.. I don't know what. I hope someone can help me. Thanks! -- Dr. Alejandro Rodríguez González - PhD Bioinformatics at Centre for Plant Biotechnology and Genomics UPM-INIA Polytechnic University of Madrid http://www.alejandrorg.com http://www.alejandrorg.com/ Phone: +34 914524900 . Ext: 25550 //Once the game is over, the king and the pawn go back in the same box. - Italian proverb//
Re: Problem inserting
Thanks Dyre! I will check all that you told me and see if I can fix the problem! Cheers On 17 April 2013 10:07, Dyre Tjeldvoll dyre.tjeldv...@oracle.com wrote: On 04/16/13 01:46 PM, Alejandro Rodríguez González wrote: Basically, I insert using this code: public void insertInputs(SetInput ri) throws Exception { PreparedStatement psInsert = null; IteratorInput it = ri.iterator(); while (it.hasNext()) { Input in = it.next(); Note that doing it this way defeats the purpose of using prepared statements, since you create and prepare it each time through the loop. A better (faster) way would be to move the call to prepareStatement out of the loop. But it does psInsert = conn .prepareStatement(insert into inputs(input_class,api) values (?, ?)); Where does conn come from here? Are you sure it is in autocommit mode? It needs to be since you don't call conn.commit() explicitly. Also, you're using the default schema for your table. Are you sure it is what you believe it to be? psInsert.setString(1, in.getObject()); If Constants.APIS[this.api] does not change as you iterate, it does not need to be a parameter. psInsert.setString(2, Constants.APIS[this.api]); this.logger.log(Inserting input in db: + in.getObject() + - API[ + Constants.APIS[this.api] + ]); I assume that you see this output when you run your program? psInsert.executeUpdate(); Place the close after the loop to re-use the prepared statement. psInsert.close(); } } It is supposed that in the following execution of my program, when I made the select statement to see the inputs in the database, it should give me results, but.. no results are provided. I attach you the first two executions of my program: First (database not created): http://pastebin.com/1k7R8Yup Second (database created. It is supposed that inputs table should contain data): http://pastebin.com/yzsK1q9w So.. as far as I understand, something is wrong in the insert but.. I don't know what. I hope someone can help me. Thanks! -- Dr. Alejandro Rodríguez González - PhD Bioinformatics at Centre for Plant Biotechnology and Genomics UPM-INIA Polytechnic University of Madrid http://www.alejandrorg.com http://www.alejandrorg.com/ Phone: +34 914524900 . Ext: 25550 //Once the game is over, the king and the pawn go back in the same box. - Italian proverb// -- Dr. Alejandro Rodríguez González - PhD Bioinformatics at Centre for Plant Biotechnology and Genomics UPM-INIA Polytechnic University of Madrid http://www.alejandrorg.com Phone: +34 914524900 . Ext: 25550 *Once the game is over, the king and the pawn go back in the same box. - Italian proverb*
Problem inserting
Hello all, I've a problem with a very fool piece of code, but, I don't know why is not working. The thing is that I want to get some data from a SPARQL endpoint, and add it to the database. The idea is that the data from the endpoint can be updated from time to tome, so, I use set theory to see the differences and only add the new data to my Apache derby db. I use the following code: Logic: http://pastebin.com/RLECrsdX DerbyDBManager: http://pastebin.com/8KWbpVNf (I left only the interesting part). So, from my main, I execute this code: Logic l = new Logic(Constants.JENA, Constants.HERMIT, Constants.FROM_INPUT_TO_OUTPUT); if (l.prepareDB().getResult()) { l.loadInAndOutsToDB(); } First of all, I prepare the db (prepareDB()) that basically load the driver, protocol and so on and creates the connection. After that, I check if the basic tables exists. If not, I create them (DerbyDBManager.createSchema()). After that, I execute Logic.loadInAndOutsToDB() which, basically, loads the data from the SPARQL Endpoint (this works fine), createOutputInputPairs (something that I need to do which also works fine) and processInputs. In processInputs() basically, I get the inputs from the database, I have the inputs from the SPARQL Endpoint, and using Set theory I made the difference, to see which inputs I should insert in the database. This works fine, but, when I try to insert the inputs in the database (using DerbyDBManager.insertInputs() it seems that is not working. Basically, I insert using this code: public void insertInputs(SetInput ri) throws Exception { PreparedStatement psInsert = null; IteratorInput it = ri.iterator(); while (it.hasNext()) { Input in = it.next(); psInsert = conn .prepareStatement(insert into inputs(input_class,api) values (?, ?)); psInsert.setString(1, in.getObject()); psInsert.setString(2, Constants.APIS[this.api]); this.logger.log(Inserting input in db: + in.getObject() + - API[ + Constants.APIS[this.api] + ]); psInsert.executeUpdate(); psInsert.close(); } } It is supposed that in the following execution of my program, when I made the select statement to see the inputs in the database, it should give me results, but.. no results are provided. I attach you the first two executions of my program: First (database not created): http://pastebin.com/1k7R8Yup Second (database created. It is supposed that inputs table should contain data): http://pastebin.com/yzsK1q9w So.. as far as I understand, something is wrong in the insert but.. I don't know what. I hope someone can help me. Thanks! -- Dr. Alejandro Rodríguez González - PhD Bioinformatics at Centre for Plant Biotechnology and Genomics UPM-INIA Polytechnic University of Madrid http://www.alejandrorg.com Phone: +34 914524900 . Ext: 25550 *Once the game is over, the king and the pawn go back in the same box. - Italian proverb*
Re: Problem inserting
On 16/04/2013 14:46, Alejandro Rodríguez González wrote: Basically, I insert using this code: public void insertInputs(SetInput ri) throws Exception { [...snip...] Don't know if it's relevant, but have you checked what ri contains on entry? I had a stupid bug once along these lines... Set remove = oldResources; Set add= newResources; if (add != null oldResources != null) { add.removeAll(oldResources); } if (remove != null newResources != null) { remove.removeAll(newResources); } ... insert the contents of add, delete the contents of remove ... which doesn't work correctly because newResources is the same set as add, so the first if has already updated it... (sometimes I hate references!) With any luck, you'll have made a similar mistake, and it'll be an easy fix. If you're smarter than I was and have avoided this particular bug, then you'll need to post the less interesting parts of your code. HTH, -- John English
Re: Problem inserting
Hi! Thanks John, I will take a look tomorrow to the code to see if this is the problem. Thanks! On 16 April 2013 19:36, John English john.fore...@gmail.com wrote: On 16/04/2013 14:46, Alejandro Rodríguez González wrote: Basically, I insert using this code: public void insertInputs(SetInput ri) throws Exception { [...snip...] Don't know if it's relevant, but have you checked what ri contains on entry? I had a stupid bug once along these lines... Set remove = oldResources; Set add= newResources; if (add != null oldResources != null) { add.removeAll(oldResources); } if (remove != null newResources != null) { remove.removeAll(newResources)**; } ... insert the contents of add, delete the contents of remove ... which doesn't work correctly because newResources is the same set as add, so the first if has already updated it... (sometimes I hate references!) With any luck, you'll have made a similar mistake, and it'll be an easy fix. If you're smarter than I was and have avoided this particular bug, then you'll need to post the less interesting parts of your code. HTH, -- John English -- Dr. Alejandro Rodríguez González - PhD Bioinformatics at Centre for Plant Biotechnology and Genomics UPM-INIA Polytechnic University of Madrid http://www.alejandrorg.com Phone: +34 914524900 . Ext: 25550 *Once the game is over, the king and the pawn go back in the same box. - Italian proverb*
RE: Upgrade issue from 10.5.3 - Problem inserting a record with derby 10.6.1.0
Hello all, Below is the ddl for the table that I created using 10.5.3. When arecord is inserted into tidlrblt table trigger- gls_blt_trg will push a corresponding record into tidlggls table CREATE TABLE tidlrblt ( blt_number INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1), blt VARCHAR(4000) NOT NULL, blt_size INTEGER NOT NULL, min_max_size INTEGER NOT NULL, CONSTRAINT blt_pk PRIMARY KEY (blt_number) ); CREATE TABLE tidlggls ( blt_number INTEGER DEFAULT 0 NOT NULL, tt_numberINTEGER DEFAULT 0 NOT NULL, tt_size INTEGER DEFAULT 0 NOT NULL, alias1_numberINTEGER DEFAULT 0 NOT NULL, alias1_size INTEGER DEFAULT 0 NOT NULL, alias2_numberINTEGER DEFAULT 0 NOT NULL, alias2_size INTEGER DEFAULT 0 NOT NULL, alias3_numberINTEGER DEFAULT 0 NOT NULL, alias3_size INTEGER DEFAULT 0 NOT NULL, alias4_numberINTEGER DEFAULT 0 NOT NULL, alias4_size INTEGER DEFAULT 0 NOT NULL, min_max_size INTEGER DEFAULT 0 NOT NULL, create_date CHAR (10) NOT NULL, update_date CHAR (10) NOT NULL, propagation_date CHAR (10) NOT NULL, glossary_status CHAR (10) NOT NULL, application_ver CHAR (8) DEFAULT '7.0.1' NOT NULL, time_stamp CHAR (26) NOT NULL ); CREATE TRIGGER gls_blt_trg AFTER INSERT ON tidlrblt INSERT INTO tidlggls(blt_number,create_date,update_date,propagation_date,glossary_status, time_stamp,min_max_size ) VALUES ( (select max(blt_number) from tidlrblt), CURRENT_DATE, CURRENT_DATE, CURRENT_DATE, '00' , CURRENT_TIMESTAMP, (select min_max_size from tidlrblt where blt_number = (select max(blt_number) from tidlrblt))); INSERT INTO tidlrblt(BLT,BLT_SIZE,MIN_MAX_SIZE) VALUES('Mamatha Testing2', 15, 20); Lily, as you doubt triggers are causing some issue. Because insert into a simple table created in 10.5.3 works. Please ret-try at your end and let me know your thoughts. Thanks again Mamatha -Original Message- From: Mamta Satoor [mailto:msat...@gmail.com] Sent: Wednesday, October 06, 2010 2:45 AM To: Derby Discussion Subject: Re: Upgrade issue from 10.5.3 - Problem inserting a record with derby 10.6.1.0 Hi Mamatha, Like Lily mentioned, it will be very helpful to have a setup script for the tables in questions to reproduce the problem. Would it possible for you to provide that? Mamta On Tue, Oct 5, 2010 at 10:41 AM, Lily Wei lily...@yahoo.com wrote: Hi Mamatha: Are you using trigger in 10.5? Do you have the definition of those trigger? i.e. the SQL statement. Thanks, Lily From: Lily Wei lily...@yahoo.com To: derby-user@db.apache.org Sent: Tue, October 5, 2010 10:16:54 AM Subject: Re: Upgrade issue from 10.5.3 - Problem inserting a record with derby 10.6.1.0 Hi Mamath: Before you do upgrade=true, were you doing a softupgrade? I just try upgrade from 10.5 to 10.6.2.1(the release candidate) with softupgrade. I did not see the Exception with my try. This is what I did: On 10.5 == ij version 10.5 ij connect 'jdbc:derby:TestDerbyDB;user=admin;password=password;create=true'; ij create table tidlrblt(BLT char(10), BLT_SIZE int, MIN_MAX_SIZE int); 0 rows inserted/updated/deleted ij insert into tidlrblt values ('Test 1', 15, 20); 1 row inserted/updated/deleted ij insert into tidlrblt values ('Test 2', 20, 25); 1 row inserted/updated/deleted ij insert into tidlrblt values ('Test 3', 25, 30); 1 row inserted/updated/deleted ij select * from tidlrblt; BLT |BLT_SIZE |MIN_MAX_SI -- Test 1 |15 |20 Test 2 |20 |25 Test 3 |25 |30 3 rows selected up $ export CLASSPATH=.;c:/derby/10.6/tools/java/junit.jar;c:/derby/10.6/jars/san e/derbyrun.jar;c:/derby/10.6/jars/sane/derbyTesting.jar;c:/derby/10.6/tools/jar s/java/jakarta-oro-2.0.8.jar l...@lily-pc /c/derby/10.5/testtmp $ ij ij version 10.6 ij connect 'jdbc:derby:TestDerbyDB;user=admin;password=password'; ij insert into tidlrblt values ('TUpdate 1.', 30, 35); 1 row inserted/updated/deleted ij select * from tidlrblt; BLT |BLT_SIZE |MIN_MAX_SI -- Test 1 |15 |20 Test 2 |20 |25 Test 3 |25 |30 TUpdate 1.|30 |35 4 rows selected Do you see you are doing anything different with you upgrade step before try the upgrade=true option? If I miss anything, please feel free to comment. Thanks, Lily From: Mamatha Kodigehalli Venkatesh mamatha.venkat...@ness.com To: Derby Discussion derby-user@db.apache.org Sent: Tue, October 5, 2010 5:50:11 AM Subject: Upgrade issue from 10.5.3 - Problem inserting a record with derby 10.6.1.0 Hello all, Currently I have my tables with data that was created
Re: Upgrade issue from 10.5.3 - Problem inserting a record with derby 10.6.1.0
On 10/6/2010 12:07 AM, Mamatha Kodigehalli Venkatesh wrote: Hello all, Below is the ddl for the table that I created using 10.5.3. When arecord is inserted into tidlrblt table trigger- gls_blt_trg will push a corresponding record into tidlggls table snip DDL Hi Mamatha, I am able to reproduce the issue and filed Jira issue DERBY-4835. https://issues.apache.org/jira/browse/DERBY-4835 You can work around the problem by dropping and recreating the trigger with 10.6 as in the workaround.sql script attached to that script. Would you be willing to grant your sql to Apache for use in out tests. I realize now I hit the grant button on the attachments but should not have without your approval. Thanks Kathey
Upgrade issue from 10.5.3 - Problem inserting a record with derby 10.6.1.0
Hello all, Currently I have my tables with data that was created using 10.5.3 version. Where I was able to perform all operations like select ,insert, update successfully. Now I upgraded to 10.6.1 and unable to perform insert into existing tables of the database that was created in 10.5.3 however am able to perform select update operations. NOTE : There is no problem to insert data into the newly created table for existing database that was created in the 10.5.3 I also tried Connect jdbc:derby:C:\DATA\L10NEnvSetup\DERBY\TestDerbyDB;user=admin;password=password;upgrade=true'; But end up getting ij INSERT INTO tidlrblt(BLT,BLT_SIZE,MIN_MAX_SIZE) VALUES('Mamatha Testing2', 1 5, 20); ERROR XJ001: Java exception: 'org.apache.derby.iapi.sql.execute.ResultSetFactory .getProjectRestrictResultSet(Lorg/apache/derby/iapi/sql/execute/NoPutResultSet;L org/apache/derby/iapi/services/loader/GeneratedMethod;Lorg/apache/derby/iapi/ser vices/loader/GeneratedMethod;ILorg/apache/derby/iapi/services/loader/GeneratedMe thod;IZZDD)Lorg/apache/derby/iapi/sql/execute/NoPutResultSet;: java.lang.NoSuchM ethodError'. ij Thanks Mamatha -Original Message- From: Kristian Waagan [mailto:kristian.waa...@oracle.com] Sent: Monday, October 04, 2010 3:48 PM To: Derby Discussion Cc: Mamatha Kodigehalli Venkatesh; avinash.b...@nsn.com Subject: Re: Problem inserting a record with derby 10.6.1.0 On 01.10.10 09:44, Mamatha Kodigehalli Venkatesh wrote: Hello all, I too upgraded derby from 10.5.3.0 to 10.6.1.0, I am getting below exception When I tried to insert a record into the table using a prepared statement. java.sql.SQLException: Java exception: 'org.apache.derby.iapi.sql.execute.Result SetFactory.getProjectRestrictResultSet(Lorg/apache/derby/iapi/sql/execute/NoPutR esultSet;Lorg/apache/derby/iapi/services/loader/GeneratedMethod;Lorg/apache/derb y/iapi/services/loader/GeneratedMethod;ILorg/apache/derby/iapi/services/loader/G eneratedMethod;IZZDD)Lorg/apache/derby/iapi/sql/execute/NoPutResultSet;: java.la ng.NoSuchMethodError'. at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknow n Source) at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source) at org.apache.derby.impl.jdbc.Util.javaException(Unknown Source) at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException (Unknown Source) at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Un known Source) at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown So urce) at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown So urce) at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown So urce) at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(Un known Source) at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeUpdate(Unkno wn Source) However Iam able to insert a record into table through ij editor. Hi Mamatha, Looks like Derby is using some old generated code or something, and that the referred method no longer exists. If that's the case, there is a bug in the Derby upgrade logic. Did you boot the database with upgrade=true, or did you do a soft upgrade [1]? Also, I'm assuming that you ran with the released Derby jars and not a custom build. Regards, -- Kristian [1] http://wiki.apache.org/db-derby/UpgradingTen Thanks Mamatha *From:* Lily Wei [mailto:lily...@yahoo.com] *Sent:* Tuesday, September 21, 2010 1:49 AM *To:* Derby Discussion *Cc:* avinash.b...@nsn.com *Subject:* Re: Problem! Hi Avinash: You can find the changes from 10.5.3.0 to 10.6.1.0 in here: http://wiki.apache.org/db-derby/DerbyTenSixOneRelease Does your application change behavior because of new features? As Kristian point out, the trace will give us more information in turn of which part of Derby the problem occurs along with what operation is performed to upgrade derby from 10.5.3.0 to 10.6.1.0. Hope this help, Lily *From:* Kristian Waagan kristian.waa...@oracle.com *To:* derby-user@db.apache.org *Sent:* Fri, September 17, 2010 3:47:21 AM *Subject:* Re: Problem! On 17.09.10 12:11, Bhat, Avinash (NSN - IN/Bangalore) wrote: Hi, This is avinash bhat, I am facing a problem in derby upgrade. Currently I have 10.5.0.3 version installed in my system and when I tried upgrading it to 10.6.0.1 my software is not able to load it is throwing null pointer exception. But it is able to create databases for the first time and if database already exist it says Null pointer exception. Can I know what is the problem which I am facing? Or do I know what major difference that you people have made between
Re: Upgrade issue from 10.5.3 - Problem inserting a record with derby 10.6.1.0
Hi Mamath: Before you do upgrade=true, were you doing a softupgrade? I just try upgrade from 10.5 to 10.6.2.1(the release candidate) with softupgrade. I did not see the Exception with my try. This is what I did: On 10.5 == ij version 10.5 ij connect 'jdbc:derby:TestDerbyDB;user=admin;password=password;create=true'; ij create table tidlrblt(BLT char(10), BLT_SIZE int, MIN_MAX_SIZE int); 0 rows inserted/updated/deleted ij insert into tidlrblt values ('Test 1', 15, 20); 1 row inserted/updated/deleted ij insert into tidlrblt values ('Test 2', 20, 25); 1 row inserted/updated/deleted ij insert into tidlrblt values ('Test 3', 25, 30); 1 row inserted/updated/deleted ij select * from tidlrblt; BLT |BLT_SIZE |MIN_MAX_SI -- Test 1|15 |20 Test 2|20 |25 Test 3|25 |30 3 rows selectedup $ export CLASSPATH=.;c:/derby/10.6/tools/java/junit.jar;c:/derby/10.6/jars/san e/derbyrun.jar;c:/derby/10.6/jars/sane/derbyTesting.jar;c:/derby/10.6/tools/jar s/java/jakarta-oro-2.0.8.jar l...@lily-pc /c/derby/10.5/testtmp $ ij ij version 10.6 ij connect 'jdbc:derby:TestDerbyDB;user=admin;password=password'; ij insert into tidlrblt values ('TUpdate 1.', 30, 35); 1 row inserted/updated/deleted ij select * from tidlrblt; BLT |BLT_SIZE |MIN_MAX_SI -- Test 1|15 |20 Test 2|20 |25 Test 3|25 |30 TUpdate 1.|30 |35 4 rows selected Do you see you are doing anything different with you upgrade step before try the upgrade=true option? If I miss anything, please feel free to comment. Thanks, Lily From: Mamatha Kodigehalli Venkatesh mamatha.venkat...@ness.com To: Derby Discussion derby-user@db.apache.org Sent: Tue, October 5, 2010 5:50:11 AM Subject: Upgrade issue from 10.5.3 - Problem inserting a record with derby 10.6.1.0 Hello all, Currently I have my tables with data that was created using 10.5.3 version. Where I was able to perform all operations like select ,insert, update successfully. Now I upgraded to 10.6.1 and unable to perform insert into existing tables of the database that was created in 10.5.3 however am able to perform select update operations. NOTE : There is no problem to insert data into the newly created table for existing database that was created in the 10.5.3 I also tried Connect jdbc:derby:C:\DATA\L10NEnvSetup\DERBY\TestDerbyDB;user=admin;password=password;upgrade=true'; But end up getting ij INSERT INTO tidlrblt(BLT,BLT_SIZE,MIN_MAX_SIZE) VALUES('Mamatha Testing2', 1 5, 20); ERROR XJ001: Java exception: 'org.apache.derby.iapi.sql.execute.ResultSetFactory .getProjectRestrictResultSet(Lorg/apache/derby/iapi/sql/execute/NoPutResultSet;L org/apache/derby/iapi/services/loader/GeneratedMethod;Lorg/apache/derby/iapi/ser vices/loader/GeneratedMethod;ILorg/apache/derby/iapi/services/loader/GeneratedMe thod;IZZDD)Lorg/apache/derby/iapi/sql/execute/NoPutResultSet;: java.lang.NoSuchM ethodError'. ij Thanks Mamatha
Re: Upgrade issue from 10.5.3 - Problem inserting a record with derby 10.6.1.0
Hi Mamatha: Are you using trigger in 10.5? Do you have the definition of those trigger? i.e. the SQL statement. Thanks, Lily From: Lily Wei lily...@yahoo.com To: derby-user@db.apache.org Sent: Tue, October 5, 2010 10:16:54 AM Subject: Re: Upgrade issue from 10.5.3 - Problem inserting a record with derby 10.6.1.0 Hi Mamath: Before you do upgrade=true, were you doing a softupgrade? I just try upgrade from 10.5 to 10.6.2.1(the release candidate) with softupgrade. I did not see the Exception with my try. This is what I did: On 10.5 == ij version 10.5 ij connect 'jdbc:derby:TestDerbyDB;user=admin;password=password;create=true'; ij create table tidlrblt(BLT char(10), BLT_SIZE int, MIN_MAX_SIZE int); 0 rows inserted/updated/deleted ij insert into tidlrblt values ('Test 1', 15, 20); 1 row inserted/updated/deleted ij insert into tidlrblt values ('Test 2', 20, 25); 1 row inserted/updated/deleted ij insert into tidlrblt values ('Test 3', 25, 30); 1 row inserted/updated/deleted ij select * from tidlrblt; BLT |BLT_SIZE |MIN_MAX_SI -- Test 1|15 |20 Test 2|20 |25 Test 3|25 |30 3 rows selectedup $ export CLASSPATH=.;c:/derby/10.6/tools/java/junit.jar;c:/derby/10.6/jars/san e/derbyrun.jar;c:/derby/10.6/jars/sane/derbyTesting.jar;c:/derby/10.6/tools/jar s/java/jakarta-oro-2.0.8.jar l...@lily-pc /c/derby/10.5/testtmp $ ij ij version 10.6 ij connect 'jdbc:derby:TestDerbyDB;user=admin;password=password'; ij insert into tidlrblt values ('TUpdate 1.', 30, 35); 1 row inserted/updated/deleted ij select * from tidlrblt; BLT |BLT_SIZE |MIN_MAX_SI -- Test 1|15 |20 Test 2|20 |25 Test 3|25 |30 TUpdate 1.|30 |35 4 rows selected Do you see you are doing anything different with you upgrade step before try the upgrade=true option? If I miss anything, please feel free to comment. Thanks, Lily From: Mamatha Kodigehalli Venkatesh mamatha.venkat...@ness.com To: Derby Discussion derby-user@db.apache.org Sent: Tue, October 5, 2010 5:50:11 AM Subject: Upgrade issue from 10.5.3 - Problem inserting a record with derby 10.6.1.0 Hello all, Currently I have my tables with data that was created using 10.5.3 version. Where I was able to perform all operations like select ,insert, update successfully. Now I upgraded to 10.6.1 and unable to perform insert into existing tables of the database that was created in 10.5.3 however am able to perform select update operations. NOTE : There is no problem to insert data into the newly created table for existing database that was created in the 10.5.3 I also tried Connect jdbc:derby:C:\DATA\L10NEnvSetup\DERBY\TestDerbyDB;user=admin;password=password;upgrade=true'; But end up getting ij INSERT INTO tidlrblt(BLT,BLT_SIZE,MIN_MAX_SIZE) VALUES('Mamatha Testing2', 1 5, 20); ERROR XJ001: Java exception: 'org.apache.derby.iapi.sql.execute.ResultSetFactory .getProjectRestrictResultSet(Lorg/apache/derby/iapi/sql/execute/NoPutResultSet;L org/apache/derby/iapi/services/loader/GeneratedMethod;Lorg/apache/derby/iapi/ser vices/loader/GeneratedMethod;ILorg/apache/derby/iapi/services/loader/GeneratedMe thod;IZZDD)Lorg/apache/derby/iapi/sql/execute/NoPutResultSet;: java.lang.NoSuchM ethodError'. ij Thanks Mamatha
Re: Upgrade issue from 10.5.3 - Problem inserting a record with derby 10.6.1.0
Hi Mamatha, Like Lily mentioned, it will be very helpful to have a setup script for the tables in questions to reproduce the problem. Would it possible for you to provide that? Mamta On Tue, Oct 5, 2010 at 10:41 AM, Lily Wei lily...@yahoo.com wrote: Hi Mamatha: Are you using trigger in 10.5? Do you have the definition of those trigger? i.e. the SQL statement. Thanks, Lily From: Lily Wei lily...@yahoo.com To: derby-user@db.apache.org Sent: Tue, October 5, 2010 10:16:54 AM Subject: Re: Upgrade issue from 10.5.3 - Problem inserting a record with derby 10.6.1.0 Hi Mamath: Before you do upgrade=true, were you doing a softupgrade? I just try upgrade from 10.5 to 10.6.2.1(the release candidate) with softupgrade. I did not see the Exception with my try. This is what I did: On 10.5 == ij version 10.5 ij connect 'jdbc:derby:TestDerbyDB;user=admin;password=password;create=true'; ij create table tidlrblt(BLT char(10), BLT_SIZE int, MIN_MAX_SIZE int); 0 rows inserted/updated/deleted ij insert into tidlrblt values ('Test 1', 15, 20); 1 row inserted/updated/deleted ij insert into tidlrblt values ('Test 2', 20, 25); 1 row inserted/updated/deleted ij insert into tidlrblt values ('Test 3', 25, 30); 1 row inserted/updated/deleted ij select * from tidlrblt; BLT |BLT_SIZE |MIN_MAX_SI -- Test 1 |15 |20 Test 2 |20 |25 Test 3 |25 |30 3 rows selected up $ export CLASSPATH=.;c:/derby/10.6/tools/java/junit.jar;c:/derby/10.6/jars/san e/derbyrun.jar;c:/derby/10.6/jars/sane/derbyTesting.jar;c:/derby/10.6/tools/jar s/java/jakarta-oro-2.0.8.jar l...@lily-pc /c/derby/10.5/testtmp $ ij ij version 10.6 ij connect 'jdbc:derby:TestDerbyDB;user=admin;password=password'; ij insert into tidlrblt values ('TUpdate 1.', 30, 35); 1 row inserted/updated/deleted ij select * from tidlrblt; BLT |BLT_SIZE |MIN_MAX_SI -- Test 1 |15 |20 Test 2 |20 |25 Test 3 |25 |30 TUpdate 1.|30 |35 4 rows selected Do you see you are doing anything different with you upgrade step before try the upgrade=true option? If I miss anything, please feel free to comment. Thanks, Lily From: Mamatha Kodigehalli Venkatesh mamatha.venkat...@ness.com To: Derby Discussion derby-user@db.apache.org Sent: Tue, October 5, 2010 5:50:11 AM Subject: Upgrade issue from 10.5.3 - Problem inserting a record with derby 10.6.1.0 Hello all, Currently I have my tables with data that was created using 10.5.3 version. Where I was able to perform all operations like select ,insert, update successfully. Now I upgraded to 10.6.1 and unable to perform insert into existing tables of the database that was created in 10.5.3 however am able to perform select update operations. NOTE : There is no problem to insert data into the newly created table for existing database that was created in the 10.5.3 I also tried Connect jdbc:derby:C:\DATA\L10NEnvSetup\DERBY\TestDerbyDB;user=admin;password=password;upgrade=true'; But end up getting ij INSERT INTO tidlrblt(BLT,BLT_SIZE,MIN_MAX_SIZE) VALUES('Mamatha Testing2', 1 5, 20); ERROR XJ001: Java exception: 'org.apache.derby.iapi.sql.execute.ResultSetFactory .getProjectRestrictResultSet(Lorg/apache/derby/iapi/sql/execute/NoPutResultSet;L org/apache/derby/iapi/services/loader/GeneratedMethod;Lorg/apache/derby/iapi/ser vices/loader/GeneratedMethod;ILorg/apache/derby/iapi/services/loader/GeneratedMe thod;IZZDD)Lorg/apache/derby/iapi/sql/execute/NoPutResultSet;: java.lang.NoSuchM ethodError'. ij Thanks Mamatha
Re: Problem inserting a record with derby 10.6.1.0
On 01.10.10 09:44, Mamatha Kodigehalli Venkatesh wrote: Hello all, I too upgraded derby from 10.5.3.0 to 10.6.1.0, I am getting below exception When I tried to insert a record into the table using a prepared statement. java.sql.SQLException: Java exception: 'org.apache.derby.iapi.sql.execute.Result SetFactory.getProjectRestrictResultSet(Lorg/apache/derby/iapi/sql/execute/NoPutR esultSet;Lorg/apache/derby/iapi/services/loader/GeneratedMethod;Lorg/apache/derb y/iapi/services/loader/GeneratedMethod;ILorg/apache/derby/iapi/services/loader/G eneratedMethod;IZZDD)Lorg/apache/derby/iapi/sql/execute/NoPutResultSet;: java.la ng.NoSuchMethodError'. at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknow n Source) at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source) at org.apache.derby.impl.jdbc.Util.javaException(Unknown Source) at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException (Unknown Source) at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Un known Source) at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown So urce) at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown So urce) at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown So urce) at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(Un known Source) at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeUpdate(Unkno wn Source) However Iam able to insert a record into table through ij editor. Hi Mamatha, Looks like Derby is using some old generated code or something, and that the referred method no longer exists. If that's the case, there is a bug in the Derby upgrade logic. Did you boot the database with upgrade=true, or did you do a soft upgrade [1]? Also, I'm assuming that you ran with the released Derby jars and not a custom build. Regards, -- Kristian [1] http://wiki.apache.org/db-derby/UpgradingTen Thanks Mamatha *From:* Lily Wei [mailto:lily...@yahoo.com] *Sent:* Tuesday, September 21, 2010 1:49 AM *To:* Derby Discussion *Cc:* avinash.b...@nsn.com *Subject:* Re: Problem! Hi Avinash: You can find the changes from 10.5.3.0 to 10.6.1.0 in here: http://wiki.apache.org/db-derby/DerbyTenSixOneRelease Does your application change behavior because of new features? As Kristian point out, the trace will give us more information in turn of which part of Derby the problem occurs along with what operation is performed to upgrade derby from 10.5.3.0 to 10.6.1.0. Hope this help, Lily *From:* Kristian Waagan kristian.waa...@oracle.com *To:* derby-user@db.apache.org *Sent:* Fri, September 17, 2010 3:47:21 AM *Subject:* Re: Problem! On 17.09.10 12:11, Bhat, Avinash (NSN - IN/Bangalore) wrote: Hi, This is avinash bhat, I am facing a problem in derby upgrade. Currently I have 10.5.0.3 version installed in my system and when I tried upgrading it to 10.6.0.1 my software is not able to load it is throwing null pointer exception. But it is able to create databases for the first time and if database already exist it says Null pointer exception. Can I know what is the problem which I am facing? Or do I know what major difference that you people have made between 10.5.0.3 and 10.6.0.1? Hi Avinash, I don't know why you get this error. Can you post the stack trace you get when hitting the problem? ( written to the console, or to derby.log ) Also, are you doing a hard upgrade (specifying upgrade=true in the connection URL), or are you doing a soft upgrade (no special attributes in the connection URL)? The trace may tell us in which part of Derby the problem occurs. Regards, -- Kristian With regards, Avinash Bhat
Re: Problem inserting a record with derby 10.6.1.0
On 01.10.10 10:11, Bhat, Avinash (NSN - IN/Bangalore) wrote: Hi We /Kristian , our application supports SHA 1 as a default but the default in derby 10.6.1.0 is SHA 256. I Tried changing that to the supporting algorithm by out application. It Fine now. Working fine. Thanks for your kind information and help. Hi Avinash, Great to hear that it is working for you now. However, Derby should not fail with a NullPointerException. If you still have the stack trace laying around, do you mind posting it to the list? (we only need the lines referring to Derby code, see also http://wiki.apache.org/db-derby/UnwindExceptionChain ) Regards, -- Kristian ** *Best Regards,* *Avinash V.Bhat| Nokia Siemens Networks | SPA2* |( +91 (80) 4363 2091(Direct) | ( (858) 2091(VOIP) | y : avinash.b...@nsn.com *From:* ext Mamatha Kodigehalli Venkatesh [mailto:mamatha.venkat...@ness.com] *Sent:* Friday, October 01, 2010 1:14 PM *To:* Derby Discussion; derby-user-i...@db.apache.org; derby-user-...@db.apache.org *Cc:* Bhat, Avinash (NSN - IN/Bangalore); kristian.waa...@oracle.com; lily...@yahoo.com *Subject:* RE: Problem inserting a record with derby 10.6.1.0 Hello all, I too upgraded derby from 10.5.3.0 to 10.6.1.0, I am getting below exception When I tried to insert a record into the table using a prepared statement. java.sql.SQLException: Java exception: 'org.apache.derby.iapi.sql.execute.Result SetFactory.getProjectRestrictResultSet(Lorg/apache/derby/iapi/sql/execute/NoPutR esultSet;Lorg/apache/derby/iapi/services/loader/GeneratedMethod;Lorg/apache/derb y/iapi/services/loader/GeneratedMethod;ILorg/apache/derby/iapi/services/loader/G eneratedMethod;IZZDD)Lorg/apache/derby/iapi/sql/execute/NoPutResultSet;: java.la ng.NoSuchMethodError'. at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknow n Source) at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source) at org.apache.derby.impl.jdbc.Util.javaException(Unknown Source) at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException (Unknown Source) at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Un known Source) at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown So urce) at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown So urce) at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown So urce) at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(Un known Source) at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeUpdate(Unkno wn Source) However Iam able to insert a record into table through ij editor. Thanks Mamatha *From:* Lily Wei [mailto:lily...@yahoo.com] *Sent:* Tuesday, September 21, 2010 1:49 AM *To:* Derby Discussion *Cc:* avinash.b...@nsn.com *Subject:* Re: Problem! Hi Avinash: You can find the changes from 10.5.3.0 to 10.6.1.0 in here: http://wiki.apache.org/db-derby/DerbyTenSixOneRelease Does your application change behavior because of new features? As Kristian point out, the trace will give us more information in turn of which part of Derby the problem occurs along with what operation is performed to upgrade derby from 10.5.3.0 to 10.6.1.0. Hope this help, Lily *From:* Kristian Waagan kristian.waa...@oracle.com *To:* derby-user@db.apache.org *Sent:* Fri, September 17, 2010 3:47:21 AM *Subject:* Re: Problem! On 17.09.10 12:11, Bhat, Avinash (NSN - IN/Bangalore) wrote: Hi, This is avinash bhat, I am facing a problem in derby upgrade. Currently I have 10.5.0.3 version installed in my system and when I tried upgrading it to 10.6.0.1 my software is not able to load it is throwing null pointer exception. But it is able to create databases for the first time and if database already exist it says Null pointer exception. Can I know what is the problem which I am facing? Or do I know what major difference that you people have made between 10.5.0.3 and 10.6.0.1? Hi Avinash, I don't know why you get this error. Can you post the stack trace you get when hitting the problem? ( written to the console, or to derby.log ) Also, are you doing a hard upgrade (specifying upgrade=true in the connection URL), or are you doing a soft upgrade (no special attributes in the connection URL)? The trace may tell us in which part of Derby the problem occurs. Regards, -- Kristian With regards, Avinash Bhat
RE: Problem inserting a record with derby 10.6.1.0
Hello all, I too upgraded derby from 10.5.3.0 to 10.6.1.0, I am getting below exception When I tried to insert a record into the table using a prepared statement. java.sql.SQLException: Java exception: 'org.apache.derby.iapi.sql.execute.Result SetFactory.getProjectRestrictResultSet(Lorg/apache/derby/iapi/sql/execute/NoPutR esultSet;Lorg/apache/derby/iapi/services/loader/GeneratedMethod;Lorg/apache/derb y/iapi/services/loader/GeneratedMethod;ILorg/apache/derby/iapi/services/loader/G eneratedMethod;IZZDD)Lorg/apache/derby/iapi/sql/execute/NoPutResultSet;: java.la ng.NoSuchMethodError'. at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknow n Source) at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source) at org.apache.derby.impl.jdbc.Util.javaException(Unknown Source) at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException (Unknown Source) at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Un known Source) at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown So urce) at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown So urce) at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown So urce) at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(Un known Source) at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeUpdate(Unkno wn Source) However Iam able to insert a record into table through ij editor. Thanks Mamatha From: Lily Wei [mailto:lily...@yahoo.com] Sent: Tuesday, September 21, 2010 1:49 AM To: Derby Discussion Cc: avinash.b...@nsn.com Subject: Re: Problem! Hi Avinash: You can find the changes from 10.5.3.0 to 10.6.1.0 in here: http://wiki.apache.org/db-derby/DerbyTenSixOneRelease http://wiki.apache.org/db-derby/DerbyTenSixOneRelease Does your application change behavior because of new features? As Kristian point out, the trace will give us more information in turn of which part of Derby the problem occurs along with what operation is performed to upgrade derby from 10.5.3.0 to 10.6.1.0. Hope this help, Lily From: Kristian Waagan kristian.waa...@oracle.com To: derby-user@db.apache.org Sent: Fri, September 17, 2010 3:47:21 AM Subject: Re: Problem! On 17.09.10 12:11, Bhat, Avinash (NSN - IN/Bangalore) wrote: Hi, This is avinash bhat, I am facing a problem in derby upgrade. Currently I have 10.5.0.3 version installed in my system and when I tried upgrading it to 10.6.0.1 my software is not able to load it is throwing null pointer exception. But it is able to create databases for the first time and if database already exist it says Null pointer exception. Can I know what is the problem which I am facing? Or do I know what major difference that you people have made between 10.5.0.3 and 10.6.0.1? Hi Avinash, I don't know why you get this error. Can you post the stack trace you get when hitting the problem? ( written to the console, or to derby.log ) Also, are you doing a hard upgrade (specifying upgrade=true in the connection URL), or are you doing a soft upgrade (no special attributes in the connection URL)? The trace may tell us in which part of Derby the problem occurs. Regards, -- Kristian With regards, Avinash Bhat
RE: Problem inserting a record with derby 10.6.1.0
Hi We /Kristian , our application supports SHA 1 as a default but the default in derby 10.6.1.0 is SHA 256. I Tried changing that to the supporting algorithm by out application. It Fine now. Working fine. Thanks for your kind information and help. Best Regards, Avinash V.Bhat| Nokia Siemens Networks | SPA2 |* +91 (80) 4363 2091(Direct) | * (858) 2091(VOIP) | * : avinash.b...@nsn.com From: ext Mamatha Kodigehalli Venkatesh [mailto:mamatha.venkat...@ness.com] Sent: Friday, October 01, 2010 1:14 PM To: Derby Discussion; derby-user-i...@db.apache.org; derby-user-...@db.apache.org Cc: Bhat, Avinash (NSN - IN/Bangalore); kristian.waa...@oracle.com; lily...@yahoo.com Subject: RE: Problem inserting a record with derby 10.6.1.0 Hello all, I too upgraded derby from 10.5.3.0 to 10.6.1.0, I am getting below exception When I tried to insert a record into the table using a prepared statement. java.sql.SQLException: Java exception: 'org.apache.derby.iapi.sql.execute.Result SetFactory.getProjectRestrictResultSet(Lorg/apache/derby/iapi/sql/execute/NoPutR esultSet;Lorg/apache/derby/iapi/services/loader/GeneratedMethod;Lorg/apache/derb y/iapi/services/loader/GeneratedMethod;ILorg/apache/derby/iapi/services/loader/G eneratedMethod;IZZDD)Lorg/apache/derby/iapi/sql/execute/NoPutResultSet;: java.la ng.NoSuchMethodError'. at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknow n Source) at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source) at org.apache.derby.impl.jdbc.Util.javaException(Unknown Source) at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException (Unknown Source) at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Un known Source) at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown So urce) at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown So urce) at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown So urce) at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(Un known Source) at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeUpdate(Unkno wn Source) However Iam able to insert a record into table through ij editor. Thanks Mamatha From: Lily Wei [mailto:lily...@yahoo.com] Sent: Tuesday, September 21, 2010 1:49 AM To: Derby Discussion Cc: avinash.b...@nsn.com Subject: Re: Problem! Hi Avinash: You can find the changes from 10.5.3.0 to 10.6.1.0 in here: http://wiki.apache.org/db-derby/DerbyTenSixOneRelease http://wiki.apache.org/db-derby/DerbyTenSixOneRelease Does your application change behavior because of new features? As Kristian point out, the trace will give us more information in turn of which part of Derby the problem occurs along with what operation is performed to upgrade derby from 10.5.3.0 to 10.6.1.0. Hope this help, Lily From: Kristian Waagan kristian.waa...@oracle.com To: derby-user@db.apache.org Sent: Fri, September 17, 2010 3:47:21 AM Subject: Re: Problem! On 17.09.10 12:11, Bhat, Avinash (NSN - IN/Bangalore) wrote: Hi, This is avinash bhat, I am facing a problem in derby upgrade. Currently I have 10.5.0.3 version installed in my system and when I tried upgrading it to 10.6.0.1 my software is not able to load it is throwing null pointer exception. But it is able to create databases for the first time and if database already exist it says Null pointer exception. Can I know what is the problem which I am facing? Or do I know what major difference that you people have made between 10.5.0.3 and 10.6.0.1? Hi Avinash, I don't know why you get this error. Can you post the stack trace you get when hitting the problem? ( written to the console, or to derby.log ) Also, are you doing a hard upgrade (specifying upgrade=true in the connection URL), or are you doing a soft upgrade (no special attributes in the connection URL)? The trace may tell us in which part of Derby the problem occurs. Regards, -- Kristian With regards, Avinash Bhat
Re: Problem Inserting Swedish Characters in Derby Database
Hi Kristian - Thank you for your help. Your suggestion was correct. After some Googling I found this page: http://illegalargumentexception.blogspot.com/2009/04/i18n-unicode-at-windows-command-prompt.html#charsets_pound which explains the problem I had. It turns out that the Windows command prompt defaults to a different code page than other parts of Windows. By changing the code page and the font for the command prompt as described in the above article, I was able to get the characters to display properly. Regards - Mark Johnson On 7/27/2010 2:41 PM, Kristian Waagan wrote: Hi Mark, Your little program produces the expected output for me. I can see both the lower and upper case versions of the three last letters in the Swedish alphabet correctly (as depicted on [1]). I copied the program from your mail and pasted it into a file using vim in my terminal. The question mark suggests a problem with your terminal settings. Are you sure you're using a locale that can display/represent those letters? (I guess things could go wrong both on the OS side and on the Java side, the machine I tested on happened to use nb_NO.UTF-8) Strings in Derby is stored as UTF-8 on disk, and are represented as Java chars when decoded or being inserted as a String/Reader. To rule out problems with storing and fetching, you could look up the Unicode code points and make sure you get back what you put in. When I did that, I could see that the code points that went in and came back out were consistent with the contents of the Unicode chart C1 Controls and Latin-1 Supplement (for instance \u00D6 and \u00E4). For completeness, which platform/OS are you seeing the trouble on?
Re: Problem Inserting Swedish Characters in Derby Database
Sorry, I forgot to mention this is with Derby 10.6.1.0 and JDK 1.6.0 update 20 on Windows 7 Professional 64-bit. Mark Johnson On 7/23/2010 10:35 PM, Mark D. Johnson wrote: Hi - I have run into a problem trying to insert the Swedish vowels Å, Ä and Ö into Varchar fields in a Derby database. I first noticed a problem with the capital Å using ij to do the insert. When I did a select on the field, the character Å was shown as a question mark. This is the only problem when I use ij - the small å and the other characters are shown correctly. I wrote a little program (listing below) to test this outside of ij, and none of the characters appear correct. It seems that the characters are being stored incorrectly, since the output from ij shows the same characters from a record inserted with the program as the program shows, and the program shows the correct vowels (with the Å replaced by a ?) for records inserted using ij. Can anyone help track down what is going wrong? Thanks for any assistance - Mark Johnson import java.sql.*; /** * * @author Mark */ public class TestClass { public static void main (String[] args) { Connection conn = null; Statement stmt = null; ResultSet rs = null; PreparedStatement ps = null; try { Class.forName(org.apache.derby.jdbc.EmbeddedDriver).newInstance(); } catch(java.lang.ClassNotFoundException e) { System.err.println(Class not found); } catch (java.lang.InstantiationException ie) { System.err.println(could not create driver instance); } catch (java.lang.IllegalAccessException iae) { System.err.println(not allowed access to driver); } try { conn = DriverManager.getConnection (jdbc:derby:testSvenskaDb;create=true;territory=sv_SE;collation=TERRITORY_BASED:PRIMARY;); } catch (Throwable e) { System.err.println(Failed to connect to database); } try { stmt = conn.createStatement (); stmt.execute (CREATE TABLE testtbl (str VARCHAR(10))); } catch (Throwable e) { System.err.println(create table failed); } try { ps = conn.prepareStatement(INSERT INTO testtbl VALUES (?)); ps.setString(1, ÅåÄäÖö); ps.executeUpdate (); } catch (Throwable e) { System.err.println(insert failed); } try { stmt = conn.createStatement(); rs = stmt.executeQuery(SELECT * FROM testtbl); while ( rs.next()) { System.out.println (rs.getString(1)); } } catch (Throwable e) { System.err.println(query failed); } try { rs.close(); stmt.close(); conn.close(); DriverManager.getConnection(jdbc:derby:;shutdown=true); } catch (SQLException se) { if (se.getSQLState().equals(XJ015)) { System.out.println(Database shut down normally); } else { System.err.println(Abnormal shutdown); } } } }
Problem Inserting Swedish Characters in Derby Database
Hi - I have run into a problem trying to insert the Swedish vowels Å, Ä and Ö into Varchar fields in a Derby database. I first noticed a problem with the capital Å using ij to do the insert. When I did a select on the field, the character Å was shown as a question mark. This is the only problem when I use ij - the small å and the other characters are shown correctly. I wrote a little program (listing below) to test this outside of ij, and none of the characters appear correct. It seems that the characters are being stored incorrectly, since the output from ij shows the same characters from a record inserted with the program as the program shows, and the program shows the correct vowels (with the Å replaced by a ?) for records inserted using ij. Can anyone help track down what is going wrong? Thanks for any assistance - Mark Johnson import java.sql.*; /** * * @author Mark */ public class TestClass { public static void main (String[] args) { Connection conn = null; Statement stmt = null; ResultSet rs = null; PreparedStatement ps = null; try { Class.forName(org.apache.derby.jdbc.EmbeddedDriver).newInstance(); } catch(java.lang.ClassNotFoundException e) { System.err.println(Class not found); } catch (java.lang.InstantiationException ie) { System.err.println(could not create driver instance); } catch (java.lang.IllegalAccessException iae) { System.err.println(not allowed access to driver); } try { conn = DriverManager.getConnection (jdbc:derby:testSvenskaDb;create=true;territory=sv_SE;collation=TERRITORY_BASED:PRIMARY;); } catch (Throwable e) { System.err.println(Failed to connect to database); } try { stmt = conn.createStatement (); stmt.execute (CREATE TABLE testtbl (str VARCHAR(10))); } catch (Throwable e) { System.err.println(create table failed); } try { ps = conn.prepareStatement(INSERT INTO testtbl VALUES (?)); ps.setString(1, ÅåÄäÖö); ps.executeUpdate (); } catch (Throwable e) { System.err.println(insert failed); } try { stmt = conn.createStatement(); rs = stmt.executeQuery(SELECT * FROM testtbl); while ( rs.next()) { System.out.println (rs.getString(1)); } } catch (Throwable e) { System.err.println(query failed); } try { rs.close(); stmt.close(); conn.close(); DriverManager.getConnection(jdbc:derby:;shutdown=true); } catch (SQLException se) { if (se.getSQLState().equals(XJ015)) { System.out.println(Database shut down normally); } else { System.err.println(Abnormal shutdown); } } } }