MS Access Named Query with parameters - ucanaccess

How do I call a named query with parameters?
I have the following query in MS Access called "getColor":
SELECT * FROM WHERE Colors ID_COLOR = [PAR_ID]
I have tried unsuccessfully with CallableStatement and PreparedStatement:
connection.prepareCall("{call getColor(?)}");
connection.prepareStatement("SELECT * FROM getColor ?");
In advance thank you very much and sorry for my bad English, I am using a translator.

yes they aren't implemented yet in UCanAccess. They will be available in the 3.0.3 as stored procedure so that you'll be able to use a CallableStatement. Translators are improving.

Related

OPENROWSET for Oracle

Could anybody help me translate this query from T-SQL to PLSQL, please?
I am using SQL Developer.
UPDATE schema.Table SET PICTURES =(SELECT * FROM OPENROWSET (BULK '\\shared folder\Picture.jpg', SINGLE_BLOB) a) WHERE (personID = 1111)
Thank you!
It looks to me like you are trying to apply a single image to a single person table row by selecting from an image file external to the database.
If my understanding is correct then I suggest you investigate Oracle EXTERNAL TABLE, DIRECTORY object and DBMS_LOB package.
Using some variant of these will certainly provide the solution you need.

Sybase default owner in JDBC connection

I have some queries against a Sybase database that after some changes in our Java (JDBC) code are failing to execute because the database is returning an error message where it demands we provide the owner in front of the table name but that is something I would prefer to provide in a single place in our configuration. We are using ASE 16.
For example, we had a query like "SELECT * FROM table_name" that will not work anymore unless we specify "SELECT * FROM database_name..table_name"
I think there should be a simple answer for this but I am struggling to find one, thank you in advance.

String Aggregation that works in both oracle and postgresql

I was originally using LISTAGG to do the union of strings in oracle.
Searching for PostgreSQL I get: string_agg
I don't know if there is any way to have a function that works in both applications.
I have to do it from the query since I can't create functions
thanks for your help
Thank you all for the help, in the end I did it through functions and sub-query

Batching of queries is not allowed by J2EE compliance

I am trying to run a stand alone Java application which executes a batch of Select queries with PreparedStatement ( by using addBatch() & executeBatch() functions of PreparedStatement ) against DB2 V 9.7.
I am getting this error message at executeBatch(),
com.ibm.db2.jcc.c.lh: [ibm][db2][jcc][105][10840] Batching of queries is not allowed by J2EE compliance.
at com.ibm.db2.jcc.c.gg.c(gg.java:2566)
at com.ibm.db2.jcc.c.gg.b(gg.java:2536)
at com.ibm.db2.jcc.c.gg.executeBatch(gg.java:1421)
at
Anybody know about this error? Nothing shows up on SO or Google.
Seems pretty self-explanatory to me.
I've only ever seen INSERT/UPDATE used with addBatch.
Given that executeBatch() returns just int[] it seems obvious that it wouldn't be of much use for SELECT queries.
This should be possible if you move your logic for multiple dynamic SQL statements into a Stored Procedure. You can then issue one JDBC call to the stored procedure.

JDBC Inconsistent with LIKE

Im new with JDBC, and while executing some query i get a result that is inconsistent.
If i execute this query in sql developer (connected to a Oracle DB) i get 4 results
SELECT *
FROM someTable1 some1
JOIN someTable2 some2 on (some1.some_id= some2.other_id)
WHERE some2.some_date LIKE '01/01/01' OR some2.some_date IS NULL
Then, i load this same query from a properties file in java and execute the query and get 0 results... anyone know why this is happening? I first suspect of the single quotes in the propertie value but i dont know...
Thanks in advance and excuse my poor english! :)
The query doesn't contain any special characters which could confuse Java, the properties loader or JDBC, so you should get exactly the same results in SQL Developer and with JDBC.
In fact, SQL Developer is written in Java, so it is using JDBC to execute the queries.
Print the query to the console before you execute it to make 100% sure the code executes the query that you have in mind.
Next, you should check the type of some_date. LIKE is only defined for string types (VARCHAR and similar), not for date/time types.
Oracle has a set of helper functions to build queries for date/time types, for example:
some_date = to_date( '01/01/2001','mm/dd/yyyy')
or
TRUNC(some_date, 'DAY') = to_date( '01/01/2001','mm/dd/yyyy')
The second query strips hours, minutes, seconds, etc. from the column and will compare only days, months and years.
Note: Always use 4-digit years to avoid all kinds of odd problems.

Resources