Sample program that transfers data from MySQL to Oracle (CLOB)

Table structure in Oracle SQL> desc scott.oracletable; Name Null? Type —————————————– ——– ———- TRANSDATE NOT NULL DATE SEQUENCE_NO NOT NULL NUMBER(6) LOBDATA NOT NULL CLOB Table structure in MySQL: Name Type —————————————– ——– trandate Date sequence_no smallint(6) textfield longtext — Code: TransferMySQLToOracle.java import java.sql.*; import java.io.*; import java.lang.StringBuffer; import java.util.Date; import java.text.SimpleDateFormat; public class TransferMySQLToOracle { public static void main(String argv[]) throws Exception { // … Continue reading Sample program that transfers data from MySQL to Oracle (CLOB)

Sample JDBC program which connects to Oracle

Sample program that demonstrates using JDBC to connect to Oracle database. Source code $ cat TestConnection.java import java.sql.*; public class TestConnection { public static void main (String args []) throws SQLException, InterruptedException { DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver()); java.util.Properties props = new java.util.Properties(); // user/password@host:port:SID Connection conn = DriverManager.getConnection (“jdbc:oracle:thin:” + args[0] + “/” + args[1] + “@” + args[2] + “:” + args[3] + “:” + … Continue reading Sample JDBC program which connects to Oracle

v$session osuser/program issue when sqldeveloper and oracle client installed

In v$session osuser, program are not set when oracle client 10.2.0.1 is used when SQLDeveloper and oracle client are installed on the same machine. This issue doesn’t occur when oracle client software (10.2.0.1) is not installed with SQLDeveloper, a workaround the issue is to update the following JDBC jars in $ORACLE_HOME. The jar files can be downloaded from the following URL http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/htdocs/jdbc_10201.html. Following jars were … Continue reading v$session osuser/program issue when sqldeveloper and oracle client installed

Oracle – JDBC v$session osuser/program issue

When an java app connects to oracle depending on the driver such as osuser, program in v$session will not be set (i.e. will be NULL) in Oracle. This issue is fixed in 10.2.0.4 oracle JDBC driver which can be downloaded from the following URL (http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/htdocs/jdbc_10201.html). Another workaround this issue is to pass the value in java.util.Properties when establishing the connection. (This workaround fix depends on … Continue reading Oracle – JDBC v$session osuser/program issue

MySQL – JDBC connection example

—– Connect.java —- —- To compile c:> javac Connect.java —- Note: Make sure the CLASSPATH env is set. MySQL Connnector/J can be downloaded from http://dev.mysql.com/downloads/connector/ —- Example: CLASSPATH=mysql-connector-java-5.1.7\mysql-connector-java-5.1.7-bin.jar;. —- To run c:> java Connect — Connect.java code import java.sql.*; public class Connect { public static void main(String argv[]) throws Exception { Connection conn = null; try { String url = “jdbc:mysql://localhost:3306/test?user=root&password=root”; Class.forName(“com.mysql.jdbc.Driver”).newInstance(); conn = DriverManager.getConnection(url); … Continue reading MySQL – JDBC connection example