Created
August 14, 2014 09:42
-
-
Save JRGGRoberto/baaf1ec9df35c551dc5a to your computer and use it in GitHub Desktop.
Arquivos para integração do CRM com a LN
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To change this license header, choose License Headers in Project Properties. | |
* To change this template file, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package ltn_cot; | |
import java.sql.Connection; | |
import java.sql.DriverManager; | |
import java.sql.PreparedStatement; | |
import java.sql.ResultSet; | |
import java.sql.Statement; | |
/** | |
* | |
* @author rgomes | |
*/ | |
public class Ltn_cot { | |
/** | |
* @param args the command line arguments | |
*/ | |
public static void main(String[] args) { | |
Connection con = null; | |
String cot_id; | |
String cot_ref; | |
String cot_ps; | |
String cot_cd_frm; | |
String cot_agt_cd_nv; | |
String cot_dt; | |
String cot_status; | |
String cot_ref_rec; | |
String cot_ano; | |
String cot_est_id; | |
String cot_ter_id; | |
try { | |
String url = "jdbc:mysql://localhost:33307/jogos_ccenter"; | |
Class.forName("com.mysql.jdbc.Driver"); | |
Connection conexao = DriverManager.getConnection(url, "root", "root"); | |
System.out.println("Conexao MySQL ok!!!"); | |
Class.forName("oracle.jdbc.OracleDriver"); | |
System.out.println("Oracle JDBC driver loaded ok."); | |
con=DriverManager.getConnection("jdbc:oracle:thin:apps/[email protected]:1611:TEST"); | |
System.out.println("Conectado Oracle"); | |
String qryselect = "SELECT cot_id, cot_ref, cot_ps, cot_cd_frm, cot_agt_cd_nv, to_char(cot_dt,'YYYY-MM-DD HH24:MI:SS'), cot_status, cot_ref_rec, cot_ano, cot_est_id, cot_ter_id FROM ltn_cot@jogos_ccenter"; | |
java.sql.Statement stmtcamp = con.createStatement(); | |
ResultSet rowsCamp = stmtcamp.executeQuery(qryselect); | |
while (rowsCamp.next()) { | |
cot_id = rowsCamp.getNString(1); | |
cot_ref = rowsCamp.getNString(2); | |
cot_ps = rowsCamp.getNString(3); | |
cot_cd_frm = rowsCamp.getNString(4); | |
cot_agt_cd_nv = rowsCamp.getNString(5); | |
cot_dt = rowsCamp.getNString(6); | |
cot_status = rowsCamp.getNString(7); | |
cot_ref_rec = rowsCamp.getNString(8); | |
cot_ano = rowsCamp.getNString(9); | |
cot_est_id = rowsCamp.getNString(10); | |
cot_ter_id = rowsCamp.getNString(11); | |
Statement stmtMysql = conexao.createStatement(); | |
String qryinsert = "insert into ltn_cot (cot_id, cot_ref, cot_ps, cot_cd_frm, cot_agt_cd_nv, cot_dt, cot_status, cot_ref_rec, cot_ano, cot_est_id, cot_ter_id ) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; | |
PreparedStatement statement = conexao.prepareStatement(qryinsert); | |
statement.setString(1, cot_id); | |
statement.setString(2, cot_ref); | |
statement.setString(3, cot_ps); | |
statement.setString(4, cot_cd_frm); | |
statement.setString(5, cot_agt_cd_nv); | |
statement.setString(6, cot_dt); | |
statement.setString(7, cot_status); | |
statement.setString(8, cot_ref_rec); | |
statement.setString(9, cot_ano); | |
statement.setString(10, cot_est_id); | |
statement.setString(11, cot_ter_id); | |
int rowsInserted = statement.executeUpdate(); | |
} | |
conexao.close(); | |
con.close(); | |
System.out.println("Desconectado"); | |
} catch (Exception e) { | |
System.err.println("Exception: "+e.getMessage()); | |
System.err.println(); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ltn_v_mpe; | |
import java.sql.Connection; | |
import java.sql.DriverManager; | |
import java.sql.PreparedStatement; | |
import java.sql.ResultSet; | |
import java.sql.Statement; | |
/** | |
* | |
* @author rgomes | |
*/ | |
public class Ltn_v_mpe { | |
/** | |
* @param args the command line arguments | |
*/ | |
public static void main(String[] args) { | |
Connection con = null; | |
String mpe_ps; | |
String mpe_ref; | |
String mpe_proc; | |
String mpe_trf; | |
String mpe_status; | |
String mpe_dt; | |
String detalhe; | |
try { | |
String url = "jdbc:mysql://localhost:33307/jogos_ccenter"; | |
Class.forName("com.mysql.jdbc.Driver"); | |
Connection conexao = DriverManager.getConnection(url, "root", "root"); | |
System.out.println("Conexao MySQL ok!!!"); | |
Class.forName("oracle.jdbc.OracleDriver"); | |
System.out.println("Oracle JDBC driver loaded ok."); | |
con=DriverManager.getConnection("jdbc:oracle:thin:apps/[email protected]:1611:TEST"); | |
System.out.println("Conectado Oracle"); | |
String qryselect = "SELECT mpe_ps, mpe_ref, mpe_proc, mpe_trf, mpe_status, to_char(mpe_dt,'YYYY-MM-DD HH24:MI:SS'), detalhe FROM LTN_V_MPE@jogos_ccenter"; | |
java.sql.Statement stmtcamp = con.createStatement(); | |
ResultSet rowsCamp = stmtcamp.executeQuery(qryselect); | |
while (rowsCamp.next()) { | |
mpe_ps = rowsCamp.getNString(1); | |
mpe_ref = rowsCamp.getNString(2); | |
mpe_proc = rowsCamp.getNString(3); | |
mpe_trf = rowsCamp.getNString(4); | |
mpe_status = rowsCamp.getNString(5); | |
mpe_dt = rowsCamp.getNString(6); | |
detalhe = rowsCamp.getNString(7); | |
Statement stmtMysql = conexao.createStatement(); | |
String qryinsert = "insert into ltn_v_mpe (mpe_ps, mpe_ref, mpe_proc, mpe_trf, mpe_status, mpe_dt, detalhe) values (?, ?, ?, ?, ?, ?, ?)"; | |
PreparedStatement statement = conexao.prepareStatement(qryinsert); | |
statement.setString(1, mpe_ps); | |
statement.setString(2, mpe_ref); | |
statement.setString(3, mpe_proc); | |
statement.setString(4, mpe_trf); | |
statement.setString(5, mpe_status); | |
statement.setString(6, mpe_dt); | |
statement.setString(7, detalhe); | |
int rowsInserted = statement.executeUpdate(); | |
} | |
conexao.close(); | |
con.close(); | |
System.out.println("Desconectado"); | |
} catch (Exception e) { | |
System.err.println("Exception: "+e.getMessage()); | |
System.err.println(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Libraries:
mysql-connector-java-5.0.8-bin.jar
ojdbc6.jar