1
I need some help, I have a system that integrates Oracle with Sql Server, that worked perfectly but Sql Server was 2000, it was upgraded to Sql Server 2008, it used the jdbc 2000 driver, now I climbed through the loadjava the jdbc 4.0( sqljdbc.jar/sqljdbc4.jar), but when I do the system test, I did not insert it in Sql Server, but there are no errors, below is the class, there is something you need to change in it after the Sql Sever upgrade?
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");
}
}