There is a database on Oracle and Postgres, you need to use java to unload the necessary tables and distribute them into tables in Postgres, that is, you need to provide some data maration. I understand how to connect, but I don’t understand how to export from oracle first, and then import into postgres.
public class ConnectToOracle { final private static String driverName = "oracle.jdbc.driver.OracleDriver"; private static String url; final private static String server = ""; final private static String port = ""; final private static String sid = ""; final private static String username = ""; final private static String password = ""; private static Connection connection; private static boolean isConnected = false; /*private static Statement stmt; private static ResultSet rs;*/ private static boolean connect() { try { url = "jdbc:oracle:thin:@" + server + ":" + port + ":" + sid; System.out.println(url); Class.forName(driverName); connection = DriverManager.getConnection(url, username, password); System.out.println("connecting: " + url); if(connection.equals(null)) isConnected = false; else isConnected = true; } catch (ClassNotFoundException e) { System.out.println("ClassNotFoundException"); isConnected = false; } catch (SQLException e) { System.out.println("SQLException\n" + e.getMessage()); isConnected = false; } return isConnected; } }
I will be grateful for any explanations! thank you in advance!
createStatement
method or the like (there are several methods for preparing the request). We send data to the request or execute it right away (depending on whether we need the parameters in the request or not). Next, we get the result object: ResultSet. From this object, you can get data of various types (here dmivic.chat.ru/JDBC/mapping.doc.html about data types and their correspondence in paragraph 8.6.1 and below). - DimXenon