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
Related
We are trying to insert records into Oracle table using PutSQL and attribute Obtain Generated Keys is set to true. NiFi DBCPConnectionPool controller service is configured to use Oracle 12c and JDBC is ojdbc8.jar.
The expected value for attribute sql.generated.key should be in number but getting rowid like AAJV6hAAAAAB/qFAAA.
So do we need to do any config settings at Oracle end to return the generated sequence id instead of rowid?
Please note that the same is working as expected for PostgreSQL!
As per this,
the Oracle JDBC driver will not return the value of the id column, but instead it will return the ROW_ID (a pseudo column that identifies a specific row), to allow you to retrieve the value yourself.
Historically the Oracle driver did it this way, because previous Oracle versions didn't have identity columns.
So I have to add a processor to get the generated sequence ID from rowid.
For SQL query in Spark.
For read, we can read jdbc by
CREATE TEMPORARY TABLE jdbcTable
USING org.apache.spark.sql.jdbc
OPTIONS dbtable ...;
For write, what is the query to write the data to the remote JDBC table using SQL?
NOTE: I want it to be SQL query.
plz provide the pure "SQL query" that can write to jdbc when using HiveContext.sql(...) of SparkSQL.
An INSERT OVERWRITE TABLE will write to your database using the JDBC connection:
DROP TABLE IF EXISTS jdbcTemp;
CREATE TABLE jdbcTemp
USING org.apache.spark.sql.jdbc
OPTIONS (...);
INSERT OVERWRITE TABLE jdbcTemp
SELECT * FROM my_spark_data;
DROP TABLE jdbcTemp;
You can write the dataframe with jdbc similar to follows.
df.write.jdbc(url, "TEST.BASICCREATETEST", new Properties)
Yes, you can. If you want to save a dataframe into an existing table you can use
df.insertIntoJDBC(url, table, overwrite)
and if you want to create new table to save this dataframe, the you can use
df.createJDBCTable(url, table, allowExisting)
I have to copy data from one table to another which one table is in Oracle and one is in MSSQL Server. I want to copy the data from MSSQL Server table to Oracle table. The problem is that the MSSQL Server table has one column which is of data type ntext and the destination column in Oracle table is clob.
When I use the query
insert into oracle.table select * from sqlserver.table#mssql; I get the following error:
SQL Error: ORA-00997: illegal use of LONG datatype
Can anyone advice on this please?
I tried it through a PL/SQL Procedure and it worked. I created a cursor, passed in the values to my variables declared in VARCHAR2 and then run an EXECUTE IMMEDIATE for the INSERT INTO....SELECT * FROM <TABLE_NAME>#MSSQL.
I want to retrieve data from Oracle Data Base which has SID, Port, Host Name, User ID, Password, Data Base Name, but i don't know the format to get the data from table.
Could you give me code how to get data from table, for example let just say SID = _SID , Table= _Table, Column = _Column. Thank You.
Use JDBC API to connect and execute the SQL statements. Take a look at JDBC Oracle FAQ.
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.