does JdbcTemplate use SQL native queries by default - spring

Is the SQL used in jdbcTemplate native SQL? If yes, query will be different depending on underlaying Database. For example, MySQL vs Oracle.
return jdbcTemplate.queryForList("select * from PERSON where last_name = ?",
new Object[] {name}
);
Updated:
I found the answer here. Yes it depends on underlying DB.
How to ignore database tablename case-sensitivity using Spring's JdbcTemplate?

Related

The problem of openGauss database connection schema

we encountered a problem when migrating the database from oracle to guassdb. It is a compatible version with postgresdb, which uses schema,
For example, select * from table1
Now because gauss uses schema, our table is in a01
The query becomes select * from a01.table1, which causes all the codes to be changed during the migration. The schema is added to the front of each table name, which is too big. Is there a better solution, such as adding schema to the url connection, because we only use one schema for each project
You can configure the user's search_path in the openGauss database. This parameter can also be configured through the url parameter in the jdbc.
for example: jdbc:postgresql://localhost:5432/mydatabase?currentSchema=a1

Query JSONB through dblink (Oracle <> Postgres)

We have a local db (Oracle) where we want to query a remote db (postgres), the data to be retreived is in JSONB format.
What is the best way for achieving this ?
The tool for accessing PostgreSQL from Oracle database is GoldenGate.
The 12.2 documentation does not even list the jsonb data type, so it is probably is not supported (I guess Oracle didn't check PostgreSQL's documentation since 9.2, when json was introduced).
But then Oracle doesn't have a special JSON data type anyway, it stores JSON as VARCHAR2 or CLOB, so you can easily use a view in PostgreSQL that casts the jsonb to text and use that.

What will be the query in oracle?

How to write this sql query into Oracle.
ALTER TABLE student MODIFY 'student_balance' DOUBLE(20,5)
As i am new in oracle so can anybody suggest some good sites to learn oracle queries again
Use number instead of double
Alter table student MODIFY student_balance number(20,5)
For more refer here .

How should I read the data from different oracle schema using ado.net?

The database user has got two schemas. I need to read the data from a specific schema using ado.net. I am using OleDbConnection object to create the connection to database. Appreciate your answers.
Use SCHEMA_NAME.TABLE_NAME in your queries.
If you don't specify a schema, Oracle will look into the current schema. The schema is by default the connexion user (so if you connect with USER1 and query TABLE1, Oracle will look for the table USER1.TABLE1). You can change your current schema at any time during a session with:
ALTER SESSION SET CURRENT_SCHEMA=SCHEMA2;
You can also use synonyms to point to the correct table.

Select BigSerial Column Data from Informix Table

The scenario is like that. User will specify a database table name and the system will retrieve and display all the data stored in the specified informix database table.
Class.forName("com.informix.jdbc.IfxDriver");
Connection conn = DriverManager.getConnection(connUrl)
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select * from an_ifx_table");
The an_ifx_table is any table name specified by user. The problem is there is a column defined with BigSerial data type. So, the code will always throw an exception:
java.sql.SQLException: bigserial
at com.informix.jdbc.IfxSqli.a(IfxSqli.java:3204)
at com.informix.jdbc.IfxSqli.E(IfxSqli.java:3518)
at com.informix.jdbc.IfxSqli.dispatchMsg(IfxSqli.java:2353)
at com.informix.jdbc.IfxSqli.receiveMessage(IfxSqli.java:2269)
at com.informix.jdbc.IfxSqli.executeStatementQuery(IfxSqli.java:1428)
at com.informix.jdbc.IfxSqli.executeStatementQuery(IfxSqli.java:1401)
at com.informix.jdbc.IfxResultSet.a(IfxResultSet.java:204)
As which table the system is retrieving the data from is going to be specified by user, we can't skip or cast the column with BigSerial data type.
Any suggestion to handle this scenario?
I have just created table with SERIAL8 column, filled it with some data and I can read all data from ResultSet.
Maybe your JDBC driver is old?
I use JDBC driver from JDBC.3.50.JC5.tar. You can also try JDBC-ODBC bridge. Install Informix ClientSDK, create ODBC source and then as driver use:
sun.jdbc.odbc.JdbcOdbcDriver
and as connUrl:
jdbc:odbc:[ODBC_source_name]
On my Windows machine I use clientsdk.3.50.TC5.WIN.zip, and on Linux I use clientsdk.3.50.UC5.LINUX.tar

Resources