Oracle10g integration with Sql Server 2008 via JDBC

1

I need a help, I have a system that does integration between Oracle with Sql Server, this worked perfectly however the Sql Server was 2000, it was upgraded to Sql Server 2008, I used the 2000 jdbc driver, now I uploaded it through loadjava jdbc 4.0 (sqljdbc.jar / sqljdbc4.jar), but when I do the test on the system, I did not insert it into the Sql Server, but it does not show any errors, below is the class, there is something that needs to be changed in it after the upgrade of 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");
    }
}

<!-- begin snippet: js hide: false -->

<!-- language: lang-js -->


    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");
        }
    }
    
asked by anonymous 01.07.2015 / 23:27

0 answers