We need to create an agent in java that connects to an informix database using the JDBC driver.
Does anyone have an example code to guide us?
I cannot give you a complete solution (as it is my job to create solutions like this for my customers), but I can give you a starting point from a fully configurable "Pump" I wrote for one of my customers about 12 years ago. Don't look to close to formatting and style. As said: This is over 10 years old, but it still runs daily at the customers' servers to import and export SQL data from and to Domino databases.
You just need to have the jar file of your jdbc driver in the right path of your Domino server
You start with some imports:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.CallableStatement;
import java.sql.Types;
import java.util.Properties;
You create a properties file for your connection and create the connection using the properties file and a correct connection url:
private Properties m_lcConProp; m_lcConProp = new Properties();
m_lcConProp.put(“user”, “YourUserName”);
m_lcConProp.put(“password”, “YourPasword”);
m_lcCon = DriverManager.getConnection(“YourConnectionURL”,m_lcConProp);
Then you generate your SQL statement and execute it (select, create, update, delete, you name it...):
private Statement m_lcStmt = null; private ResultSet m_lcRs = null; private ResultSetMetaData m_lcMeta = null; private int m_intcNumberOfColumns = 0;m_lcStmt = m_lcCon.createStatement();
m_lcRs = m_lcStmt.executeQuery(“YourSQLStatement”);
m_lcMeta = m_lcRs.getMetaData();
m_intcNumberOfColumns = m_lcMeta.getColumnCount();
if you do something that returns a result, you can run through the result like this:
if( m_lcRs != null) {
while (m_lcRs.next()) {
for (int i = 0; i < m_intcNumberOfColumns; i++) {
strColumnValue = m_lcRs.getString(i+1);
// Do whatever you want with that column value...
}
}
}
We are going to upgrade domino sever to domino R14, and we have problem to connect informix database with JDBC driver, which is working on domino R9.
Should I download new version of JDBC driver? Where is the right path of your Domino server in R14?
Our operation system is RHEL 9.6
Thank you so much if any one can answer me!