Jump to content
Fórum Script Brasil
  • 0

Integração Oracle com Sql Server via JDBC


Vitor Godoi
 Share

Question

Boa tarde,

Preciso de uma ajuda, eu tenho um sistema que faz integração entre Oracle com Sql Server, isso funcionava perfeitamente porém o Sql Server era 2000, foi atualizado para Sql Server 2008, utilizava os driver do jdbc 2000, agora subi através do loadjava o jdbc 4.0( sqljdbc.jar/sqljdbc4.jar), porém quando faço o teste no sistema , não inseri no Sql Server, mas não apresenta erros, abaixo está a class, tem alguma coisa que precisa mudar nela depois do upgrade do Sql Sever?

import java.sql.*;
//import javax.sql.*;
import javax.naming.*;

public class DataTransf
{
private static Connection connFcl;


//// Connect ////

public static boolean Connect(String strConn)
{
try
{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");

}
catch(ClassNotFoundException cnfex)
{
System.err.println("Failed to load JDBC driver.");
cnfex.printStackTrace();
return false;
}

try
{
connFcl = DriverManager.getConnection(strConn);

// exemplo: "jdbc:microsoft:sqlserver://srv0001:1433;User=User;Password=PASSWORD;DatabaseName=DATABASE"

}
catch(SQLException sqlex)
{
System.err.println("Unable to connect to FCL.");
sqlex.printStackTrace();
return false;
}

return true;
}


//// ShutDown ////

public static boolean ShutDown()
{
try
{
connFcl.close();
}
catch (SQLException sqlex)
{
System.err.println("Unable to disconnect FCL.");
sqlex.printStackTrace();
return false;
}

return true;
}


//// Procedure ////

public static int Procedure(String strCmd)
{
Statement stmtFcl;
ResultSet rs;
int iRet = 0;

try
{
// System.out.println(strCmd); // debug

stmtFcl = connFcl.createStatement();
rs = stmtFcl.executeQuery(strCmd);

if(rs.next())
{
iRet = rs.getInt("Numero_Erro");
if(rs.wasNull()) iRet = 0;
}

rs.close();
stmtFcl.close();
}
catch (SQLException sqlex)
{
sqlex.printStackTrace();
return -1;
}

return iRet;
}


//// Exec ////

public static int Exec(String strCmd, String strConn)
{
int iRet;

if(!Connect(strConn)) return -1;
iRet = Procedure(strCmd);
ShutDown();

return iRet;
}


//// main ////

public static void main(String args[])
{
if(args.length == 2)
{
System.out.println("Resultado: " + Exec(args[0], args[1]));
}
else System.out.println("Usage: DataTransf strCmd strConn");
}
}

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0
Guest Ronaldsego

Квалифицированный московский мастер по морозильникам за дарма продиагностирует и выполнит прямой ремонт холодильников на Театральной тихо в трехэтажке с гарантией на всевозможные работы.Прочитать и распечатать все расценки вы можете у нас на сайте. ------------------------ ветренный холодный ремонт холодильников Библиотека имени Ленина холодный ремонт холодильников Черкизовская холодный ремонт холодильников Коломенская постоянно салонный плавкий ремонт холодильников с прожилкой

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Forum Statistics

    • Total Topics
      149.8k
    • Total Posts
      646.7k
×
×
  • Create New...