I am trying to use JDBC to insert into multiple tables. Since it should be fast, I want to use the PreparedStatementand method executeBatch. Tables are combined with a foreign key relationship.
PreparedStatement
executeBatch
The first idea was to use getGeneratedKeys(), but this failed with some JDBC drivers. For instance. PostgreSQL
getGeneratedKeys()
The second idea was to use the SQL-currval (...) function. But you need to call the execute command for one statement, and for another it makes all the keys the same. Thus, this method also fails.
JDBC does not accept comma-inserted inserts.
How can i achieve this?
PostgreSQL. , PostgreSQL JDBC 8.4-701 PreparedStatement#getGeneratedKeys() .
PreparedStatement#getGeneratedKeys()
, :
statement = connection.prepareStatement(SQL, Statement.RETURN_GENERATED_KEYS);
, . JDBC.
- JDBC "" "Hibernate" JPA. - Java .. DB.
, /, , .
.
, .
, getGeneratedKeys(), .
Postgres 9.0:
"SELECT nextval('public.\"table_column_seq\"') FROM generate_series(1,"+pollsize+")");
, , , - . JDBC , - YouVeGotaF ** ckedUpDriverException.
Source: https://habr.com/ru/post/1795782/More articles:Vertical Gradient / IE - htmlBest way to add a textview to your main game view? - androidGrammatically correct uptime in C # - c #Using .NET to verify digital signature generation using Java CXF / WSS4J application - namespace problem? - javaCustom Application Class - c #Избегание взрывающихся индексов и ограничений скорости записи в группе лиц с помощью приложения - javahttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1795784/i-have-100-movieclips-of-different-sizes-to-randomly-make-a-grid-out-of-how-would-i-optimize-this&usg=ALkJrhiQ9IRD-V5tZ8fZBE0ZB2al5evYaAUse jQuery to insert hyphen into phone # in td fields - jqueryopenlayers engine markerOnly accurate at a certain zoom level - javascriptLink to elements from a two-dimensional array with a single value - c ++All Articles