I am trying to establish a connection with Postgres DB.
ps = con.prepareStatement("SELECT * FROM procesar(?, ?, ?, ?, ?, ?, ?, ?, ?)");
ps.setQueryTimeout(TIMEOUT);
But I have the following error:
Method org.postgresql.jdbc3.Jdbc3PreparedStatement.setQueryTimeout(int) is not yet implemented.
Aparently, it's a driver issue. I use JDBC3.
My question is if there is another way to set timeout for db query? I cannot update the driver.
yes, by running following query:
set [LOCAL] statement_timeout = '1s';
LOCAL means that this setting will be applied only inside transaction, otherwise you need to reset it after query is done.
Related
This problem occurred while learning AXON 3.x. Using postgre 42.5.0 DB.
Hibernate: select nextval ('hibernate_sequence')
Hibernate: insert into domain_event_entry (event_identifier, meta_data, payload, payload_revision, payload_type, time_stamp, aggregate_identifier, sequence_number, type, global_index) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
2022-11-02 11:05:28.189 WARN 15368 --- [nio-8080-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 0, SQLState: 42P01
2022-11-02 11:05:28.189 ERROR 15368 --- [nio-8080-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper : ERROR: relation "domain_event_entry" does not exist
Position: 13
2022-11-02 11:05:28.191 INFO 15368 --- [nio-8080-exec-1] o.h.e.j.b.internal.AbstractBatchImpl : HHH000010: On release of batch it still contained JDBC statements
I think the relevant tables should be created automatically. What is wrong with the configuration?
Given you current explanation, there's not that much to go off, #zzz.
I do have two pointers for you, though:
Please move to the latest Axon Framework release. Axon Framework is currently on 4.6.2, which is about 4 years ahead from the latest minor release of Axon Framework 3.
The main thing missing from your question, is how you're configuring your application. Surely there's something wrong, but pinpointing what it is, is rather tough without knowing what you're doing. On this note though, if you are in a Spring Boot environment, adding the axon-spring-boot-starter dependency should be sufficient.
What might be an easy stepping stone for you, #zzz, is using AxonIQ's Initializr. Through the initializr, you can construct a basic Axon Framework application, allowing you to add several dependencies you may need as well.
You can find the initializr here, by the way.
I'm trying to query whether any of a set of polygons (passed in at runtime) intersects with a set of polygons stored in the database in the "enclosing_polygons" field, which is a MultiPolygonField.
Here is an example of the query:
select * from my_table where field1 = any (?) and field2 = any (?) and (
ST_Intersects(ST_GeometryFromText('POLYGON((? ?, ? ?, ? ?, ? ?, ? ?))'), enclosing_polygons) or
ST_Intersects(ST_GeometryFromText('POLYGON((? ?, ? ?, ? ?, ? ?, ? ?))'), enclosing_polygons))
and detection_type = 0 order by confidence desc limit 2000
The query works fine with hardcoded values, but when I try to parameterize it, Postgres does not seem to recognize the ? placehoders for the polygon points as parameters when I try to populate them.
When I set the first two parameters (for field1 and field2), these JDBC statements succeed:
statement.setArray(1, array1)
statement.setArray(2, array2)
However, if I try to set any parameters beyond these first two, they fail. This statement:
statement.setDouble(3, point1x)
fails with the following error:
The column index is out of range: 3, number of columns: 2.
Why does Postgres not recognize these ?s in the POLYGON constructor as query parameters?
How can I make this work?
It is up to your driver to implement the ? placeholders, PostgreSQL never sees them. In your driver, like in almost all drivers, the question marks occurring inside the single quotes are just literal question marks, not place holders.
You probably need to construct the POLYGON((...)) string yourself, then pass that whole string into the query as a single placeholder. So that part of the query would look like ST_Intersects(ST_GeometryFromText(?), enclosing_polygons)
There are alternatives but they mostly just move the problem around without directly solving it. If you really want to just use plain question marks with each bound to one number, you could replace the ST_GeometryFromText function with something like:
st_makepolygon(st_makeline(array[st_makepoint(?,?),st_makepoint(?,?),st_makepoint(?,?),st_makepoint(?,?),st_makepoint(?,?)]))
I'm running a perl script to update a currently working database with new datasets. Basically, the script receives molecule information as plain text (MDL if you are interested) and performs several chemical properties calculations through a bunch of third party softwares called via system.
The script have never had any problems processing data but the last dataset seems to have some molecules (or at least one, for what it's worth) for which some of the properties make no sense and I end up having truncated data insertions, which lastly causes a DBIC exception. Namely:
DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Column 'inchi' cannot be null [for Statement "INSERT INTO moldata ( formula, hba, hbd, inchi, inchikey, mol_id, pm, psa, ro3pass, ro5vio, rtb, smiles, xlogp3aa) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" with ParamValues: 0='I', 1='0', 2='0', 3=undef, 4='XMBWDFGMSWQBCA-YPZZEJLDSA-M', 5=936934, 6='125.00', 7='0', 8=6, 9=0, 10='0', 11='[125I-]', 12='0.86']
At this point, the program just dies. I can surely do some workarounds to avoid getting "undefs" in the inserts, but I'd like DBIC to be able to handle them and continue with the inserts while ignoring (and maybe warn me about them later) the bad ones.
What would be the right way to implement a try/catch scenario in perl for DBIC transactions?
Thanks!
I'm using scalaquery to connect to both oracle and postgres servers.
This behaviour is occuring for both Oracle and Postgres, but it's only valid (and still incorrect) SQL in Postgres.
At some point, I'm running a query in scalaquery of the form:
row.foo.bind == parameter.foo || row.foo inSetBind parameter.foo.children
Parameter is a trait, which is known to have a foo in it.
The problem here is that out of the ~100 queries run, scala-query only generates the correct SQL once, of the form
...
WHERE row.foo = ? or row.foo in (?, ?, ?, ?, ?)
...
Most of the time it instead generates
...
WHERE row.foo = ? or false
...
Why is this happening inconsistently, is it a bug (I assume it is), and how do I work around it?
It turns out that the query was looking at an empty set, because parameter.foo had no childen in most cases.
Given that WHERE row.foo IN () is not valid SQL, it was instead written out as false.
This still leaves the issue of false being generated despite the code being targeted at oracle DB, but the root cause has now been cleared up.
I have proram written using java,jps.Now i can see logs on cosole as folllows:
INSERT INTO XYZ (a,b,c) VALUES (?, ?, ?) [org.apache.openjpa.jdbc.kernel.JDBCStoreManager$CancelPreparedStatement]
I also want to see the values passed to insert query in log.How can i see it?AM using openjpa as jpa provider.
Set openjpa.ConnectionFactoryProperties=PrintParameters=True.