error on alter column with h2-1.3.154

66 views
Skip to first unread message

darkSoulLight

unread,
Apr 7, 2011, 3:34:19 AM4/7/11
to H2 Database
hi all,
with the update to version 1.3.154, i've this error when alter column
with data on my db:
org.h2.jdbc.JdbcSQLException: Unique index or primary key violation:
"PRIMARY KEY ON """".PAGE_INDEX"; SQL statement:
ALTER TABLE TbBase ALTER COLUMN BasPerc62 DOUBLE [23505-154];
State=23505; ErrorCode=23505
at org.h2.message.DbException.getJdbcSQLException(DbException.java:
327)
at org.h2.message.DbException.get(DbException.java:167)
at org.h2.message.DbException.get(DbException.java:144)
at
org.h2.index.PageDataIndex.getNewDuplicateKeyException(PageDataIndex.java:
157)
at org.h2.index.PageDataIndex.add(PageDataIndex.java:135)
at org.h2.store.PageStore.addMeta(PageStore.java:1678)
at org.h2.index.PageDataIndex.<init>(PageDataIndex.java:75)
at org.h2.table.RegularTable.<init>(RegularTable.java:92)
at org.h2.schema.Schema.createTable(Schema.java:542)
at
org.h2.command.ddl.AlterTableAlterColumn.cloneTableStructure(AlterTableAlterColumn.java:
267)
at
org.h2.command.ddl.AlterTableAlterColumn.copyData(AlterTableAlterColumn.java:
180)
at
org.h2.command.ddl.AlterTableAlterColumn.update(AlterTableAlterColumn.java:
117)
at org.h2.command.CommandContainer.update(CommandContainer.java:69)
at org.h2.command.Command.executeUpdate(Command.java:212)
at org.h2.jdbc.JdbcStatement.executeUpdateInternal(JdbcStatement.java:
125)
at org.h2.jdbc.JdbcStatement.executeUpdate(JdbcStatement.java:110)
at
it.unosistemi.gestord.aggiornamenti.AggiornaTbBase.processAggiornaPreEis(AggiornaTbBase.java:
42)
at
it.unosistemi.gestord.aggiornamenti.AggiornaTbBase.doWork(AggiornaTbBase.java:
24)
at
it.unosistemi.gestord.aggiornamenti.AggiornaTbBase.<init>(AggiornaTbBase.java:
18)
at
it.unosistemi.gestord.jfc.GestioneOrdiniJFrame.processAggiornamento(GestioneOrdiniJFrame.java:
1649)
at
it.unosistemi.gestord.jfc.GestioneOrdiniJFrame.connEtoM4(GestioneOrdiniJFrame.java:
1010)
at
it.unosistemi.gestord.jfc.GestioneOrdiniJFrame.<init>(GestioneOrdiniJFrame.java:
264)
at
it.unosistemi.gestord.jfc.GestioneOrdiniJFrame.main(GestioneOrdiniJFrame.java:
522)

is it a bug?
other detail:
when i execute query on console, first time doesn't work but second
time it works.

thanks all.

Thomas Mueller

unread,
Apr 8, 2011, 9:17:55 AM4/8/11
to h2-da...@googlegroups.com
Hi,

That's strange, do you have a reproducible test case, or could you
send me the database where this occurs?

Regards,
Thomas

darkSoulLight

unread,
Apr 9, 2011, 8:22:23 AM4/9/11
to H2 Database
Hi Thomas,
thank for your answer.
i'll send you a copy of database on monday.
Do you needjava class, too?

Thomas Mueller

unread,
Apr 9, 2011, 8:48:45 AM4/9/11
to h2-da...@googlegroups.com
Hi,

> i'll send you a copy of database on monday.

Thanks a lot! Unfortunately, I will be on vacation for two weeks, so
I'm not sure if I will have time to look at it until then.

> Do you need java class, too?

Yes, that would be nice.

Regards,
Thomas

darkSoulLight

unread,
Apr 11, 2011, 6:41:59 AM4/11/11
to H2 Database
Hi,
this is the link to download db. http://www.2shared.com/file/BMrUZjPC/Databaseh2.html

this is a code class for test db.

[code]
import junit.framework.TestCase;

public class TestDbH2Query extends TestCase {

private static java.sql.Connection connection = null;

public static java.sql.Connection getDbConnection() {
try {
if (connection == null || connection.isClosed()) {
Class.forName("org.h2.Driver");
connection = java.sql.DriverManager.getConnection("jdbc:h2:C:\
\Agord\\AgordTab", "", "");
}
} catch (Exception e) {
e.printStackTrace();
connection = null;
}
return connection;
}

public void testAlterOrNotColumn() throws Exception {
try {
String sql = "ALTER TABLE TbOvrig ALTER COLUMN OrNot
Varchar(1000)";
java.sql.Statement stmt = getDbConnection().createStatement();
stmt.executeUpdate(sql);
System.out.println("OK");
sql = "ALTER TABLE TbBase ALTER COLUMN BasPerc62 DOUBLE";
stmt.executeUpdate(sql);
System.out.println("OK");
stmt.close();
getDbConnection().close();
} catch (Exception e) {
e.printStackTrace();
}
}

}
[/code]
Thanks for your help.

Thotheolh

unread,
Apr 11, 2011, 7:52:48 AM4/11/11
to H2 Database
Hi. darkSoulLight, your database zip somehow couldn't be downloaded.

On Apr 11, 6:41 pm, darkSoulLight <dark.soul.li...@gmail.com> wrote:
> Hi,
> this is the link to download db.http://www.2shared.com/file/BMrUZjPC/Databaseh2.html

darkSoulLight

unread,
Apr 11, 2011, 8:47:39 AM4/11/11
to H2 Database
i've upload file again.
this is new link: http://www.2shared.com/file/6esz35JD/dbh2.html
i can download it.

Thomas Mueller

unread,
May 2, 2011, 3:10:26 PM5/2/11
to h2-da...@googlegroups.com
Hi,

I can't really explain currently how the database came into this
state, but I found a way to automatically correct it. So the next
version of H2 will be able to open this database and run the ALTER
TABLE statement.

But I would like to understand how the database came into this state,
so I have a few questions:

- What is your database URL?
- Do you use temporary tables?
- Did you use LOG=0 or LOG=1?
- Did the application run out of memory (once, or multiple times)?
- Do you use any settings or special features (for example cache settings,
two phase commit, linked tables)?
- Do you use any H2-specific system properties?
- Is the application multi-threaded?
- What operating system, file system, and virtual machine
(java -version) do you use?
- How did you start the Java process (java -Xmx... and so on)?
- Is it (or was it at some point) a networked file system?
- Is the database usually closed normally, or is process terminated
forcefully or the computer switched off?
- Are there any other exceptions (maybe in the .trace.db file)?
Could you send them please?
- Do you still have any .trace.db files, and if yes could you send them?

Regards,
Thomas

darkSoulLight

unread,
May 28, 2011, 5:11:46 AM5/28/11
to H2 Database
Hi Thomas,
- database connection url is : jdbc:h2:<full path db file>
- i don't use temporary tables.
- no, i don't use any LOG.
- no application don't run out of memory
- i don't use any special features
- i don't use any H2-specific system properties.
- i don't use any multi-thread in my application.
- usally application runs on windows (min XP version) with java 1.5.
sometimes application run on mac "xp simulation".
- process starts with -Xms64m and -Xmx512m.
- no there aren't any networked file system.
- yes, database usually closed normally.
- during develop phase there are some exception in trace.db file but
this isn't a develop db.
- i haven't originally db trace file.

Thanks
Reply all
Reply to author
Forward
0 new messages