Hi, I'm developing a project where i need to copy whatever Sybase has in its Database, directly into Oracle... the restriction is that i have to do this via a JAVA program, i have the Oracle and the Sybase classes and is as follows;
my code compiles, and it gives you back a Resultset for whatever you want column you want, and here comes the tricky part, which is the part I'm stuck on, how can i manipulate a Resultset in a way that i can export that information into an oracle database, do i need to create a repository table? or what else can i do?? because i can get it to display it but i need it to go into to Oracle... any suggestion would be nice, can anyone help??? thanx in adavanced for your help.
Yerman
package sybaseoracle;
import java.io.*;
import java.sql.*;
import com.sybase.jdbcx.*;
import com.sybase.jdbc3.tds.*;
import com.sybase.jdbc3.jdbc.*;
import com.sybase.jdbc3.timedio.*;
import com.sybase.jdbc3.utils.*;
import java.util.*;
import java.sql.ResultSet;
public class SybaseMainClassRS {
private static final String Make = "create table Test ( " + " id INT PRIMARY KEY, firstName VARCHAR(20), lastName VARCHAR(20), " + " title VARCHAR(20), salary VARCHAR(20) " + ")";
public static Connection getConnection() throws ClassNotFoundException, SQLException {
String driver = "com.sybase.jdbc3.jdbc.SybDataSource";
String url = "jdbc:sybase:Tds:W2VZ2DTT02:5000/testsybase";
String username = "sa";
String password = "";
Class.forName(driver);
Connection conn = DriverManager.getConnection(url, username, password);
return conn;
}
public static void main(String args[]) {
Connection conn = null;
Statement stmt = null;
try {
conn = getConnection();
stmt = conn.createStatement();
stmt.executeUpdate(Make);
stmt.executeUpdate("insert into Test(id, firstName, lastName, title, salary) values(100, 'German', 'Garcia', 'Analyst', '3000')");
stmt.executeUpdate("insert into Test(id, firstName, lastName, title, salary) values(200, 'German', 'Grajeola', 'Architect', '5000')");
System.out.println("Table Created.");
} catch (ClassNotFoundException e) {
System.out.println("error: failed to load Sybase driver.");
e.printStackTrace();
} catch (SQLException e) {
System.out.println("error: failed to create a connection object.");
e.printStackTrace();
} catch (Exception e) {
System.out.println("other error:");
e.printStackTrace();
}
try {
stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT id FROM Test WHERE id = 200");
while (rs.next()) {
System.out.println(rs.getInt(1));
}
} catch (SQLException e) {
System.out.println("Missing Query Statement");
e.printStackTrace();
} finally {
try {
stmt.close();
conn.close();
} catch (Exception e) {
System.out.println("Can't close the connection");
e.printStackTrace();
}
}
}
}