JSP Connect to Oracle with specific requirement - oracle

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.

Related

Accessing data of one DBCS to another DBCS

I have two DBCS instance. DB1 and DB2. I want to access data of DB2 instance in DB1.
I dont want to copy the data , I just want to access for reporting purpose.
Can you please help me on the same.
Within DB1, create a db link to DB2:
CREATE PUBLIC DATABASE LINK "DB2"
CONNECT TO "db2user" IDENTIFIED BY "db2userpwd"
USING 'DB2';
Create a tnsnames.ora entry (in the tnsnames.ora of the DB1 machine) for DB2
Then when you want to select the data,
select * from my_db2_table#DB2;
Read more on DB Links in the SQL Reference.create database link
BTW, in the CREATE statement above, the two strings 'DB2' do not have to be the same, but probably should be for consistency. The first (CREATE DATABASE LINK DB2) is the name of the link and is what is referenced in the sample SELECT statement. The second (using 'DB2') is the reference to the tnsnames.ora entry.

SQLite dblink to Oracle possible?

I have a SQLite database and I need to connect to an Oracle database so I can do some reports.
So my questions are:
Is it possible to create a dblink from SQLite to the Oracle database, so that I can use something like:
select *
from sqlitetable s
join oracletable#oracleserver o on o.column = s.column
where s.column = 'x'
Assuming this is indeed possible, do I need to have some setup/support from the oracle admin, or can I simply connect via my existing account?
It is, in theory, possible to write a virtual table that links to Oracle.
However, I don't know of any actual implementation.

how to create Oracle DBLink in same SID

Please let me know how to create Oracle DBLink in the same SID for two schema? To make clear, I want to connect one schema to another schema in the same Oracle server (SID).
Let's say, I have two schema called sch1 and sch2. Now, I login as sch1 and what I want is to retrieve data from sch2 (as long as I'm in sch1).
If you want to access a table in one schema from another schema, try doing the following:
connect as schema2,
run grant select on sometable to schema1,
connect as schema1,
try select * from schema2.sometable.

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