Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No AUTO_INCREMENT in DatabaseMetaData.getTypeInfo() #3567

Closed
prrvchr opened this issue Jul 4, 2022 · 9 comments · Fixed by #3568
Closed

No AUTO_INCREMENT in DatabaseMetaData.getTypeInfo() #3567

prrvchr opened this issue Jul 4, 2022 · 9 comments · Fixed by #3568

Comments

@prrvchr
Copy link

prrvchr commented Jul 4, 2022

Hi all,

I come back for my driver for LibreOffice / OpenOffice...

It seems that no DataType returned by DatabaseMetaData.getTypeInfo() has the AUTO_INCREMENT column set to true.

Normally it seems that DataType: INTEGER, BIGINT, TINYINT, SMALLINT, NUMERIC, DECIMAL could be autoincrement and have AUTO_INCREMENT column set to true.

This prevents me from being able to handle auto-increments in creating tables in Base... any workaround?

Thanks.

@prrvchr
Copy link
Author

prrvchr commented Jul 4, 2022

Hi katzyn,

Thank you for correcting it, especially so quickly!!!
Where can I find the corrected H2 jar archive.

Maybe you can help me to finish the integration of auto increment in Base?
Apparently H2 does not support a command like:

CREATE TABLE "PUBLIC"."PUBLIC"."Table1" ("ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY, "Name" NVARCHAR(100), PRIMARY KEY ("ID"))

If so, I can create the table then the index in two separate commands:
CREATE TABLE "PUBLIC"."PUBLIC"."Table1" ("ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY, "Name" NVARCHAR(100))

ALTER TABLE "PUBLIC"."PUBLIC"."Table1" ADD INDEX .....

I don't know the second command...
Thanks.

@katzyn
Copy link
Contributor

katzyn commented Jul 4, 2022

Where can I find the corrected H2 jar archive.

You need to compile H2 from its current sources by yourself. I don't think a new version of H2 will be released in the near future.

Building instructions are here:
https://h2database.com/html/build.html#building

You need a jar target. Use JDK 8 or some newer version.

Maybe you can help me to finish the integration of auto increment in Base? Apparently H2 does not support a command like:

CREATE TABLE "PUBLIC"."PUBLIC"."Table1" ("ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY, "Name" NVARCHAR(100), PRIMARY KEY ("ID"))

You cannot specify a name of a catalog in table definitions of H2 and H2 doesn't support multiple catalogs, there is always only one catalog with the same name as a name of database. You need to replace "PUBLIC"."PUBLIC"."Table1" with "PUBLIC"."Table1".

Also NOT NULL may normally be specified only after GENERATED BY DEFAULT AS IDENTITY, but H2 allows this incorrect order of clauses for a some limited compatibility with broken scripts and applications. Actually this NOT NULL clause isn't needed here at all, because identity columns aren't nullable and primary key columns aren't nullable even if they don't have an explicit null constraint.

There are no indexes in this definition.

@prrvchr
Copy link
Author

prrvchr commented Jul 4, 2022

After new test I realize that the creation of tables with autoincrement works perfectly. I must have made mistakes on my side, I'm sorry...

I will try to compile the corrected version, thank you for your reactivity...

@prrvchr
Copy link
Author

prrvchr commented Jul 4, 2022

I try to compile in Eclipse but many dependency are missing...
Have you a list of all jar needed?

I dont find for:

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

and
import org.locationtech.jts.geom.Geometry;

Thanks

@katzyn
Copy link
Contributor

katzyn commented Jul 4, 2022

Build script mentioned in building instructions is can download everything from Maven Central, you need to launch it at least once to get dependencies.

@prrvchr
Copy link
Author

prrvchr commented Jul 4, 2022

I have already run the command ./build.sh download in the h2 folder after an JAVA_HOME=/lib/jvm/default-java
But if I want no error in eclipse I need a lib folder with:

jakarta.servlet-api-6.0.0.jar
lucene-core-9.2.0.jar
lucene-queryparser-9.2.0.jar
slf4j-api.jar

Maybe I digress...

@katzyn
Copy link
Contributor

katzyn commented Jul 4, 2022

You need to refresh your project. After that you can add all jars from h2/ext directory to build path of your project.

@prrvchr
Copy link
Author

prrvchr commented Jul 4, 2022

You are right katzyn, I had not seen the ext folder under h2... Thank you very much

@prrvchr
Copy link
Author

prrvchr commented Jul 4, 2022

I can compile with 2 error:

Description	Resource	Path	Location	Type
The type Bits is already defined	Bits.java	/h2/src/main/org/h2/util	line 15	Java Problem
The type Utils10 is already defined	Utils10.java	/h2/src/main/org/h2/util	line 20	Java Problem

But the archive gives me satisfaction I can create tables with autoincrement... Thanks again...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants