Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/336.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
是因为一些配置问题吗?请建议帮助我。迁移到2008年?你仍然落后了五年。这就是我们在我们的程序中使用的方式,我在谷歌上搜索过,但没有运气。关于这个问题,我连一点线索都找不到。你能建议我一些步骤来找出这个问题的原因吗。 Java call terminate_Java_Sql_Sql Server 2008_Sql Server 2005_Runtime Error - Fatal编程技术网

是因为一些配置问题吗?请建议帮助我。迁移到2008年?你仍然落后了五年。这就是我们在我们的程序中使用的方式,我在谷歌上搜索过,但没有运气。关于这个问题,我连一点线索都找不到。你能建议我一些步骤来找出这个问题的原因吗。 Java call terminate

是因为一些配置问题吗?请建议帮助我。迁移到2008年?你仍然落后了五年。这就是我们在我们的程序中使用的方式,我在谷歌上搜索过,但没有运气。关于这个问题,我连一点线索都找不到。你能建议我一些步骤来找出这个问题的原因吗。 Java call terminate,java,sql,sql-server-2008,sql-server-2005,runtime-error,Java,Sql,Sql Server 2008,Sql Server 2005,Runtime Error,是因为一些配置问题吗?请建议帮助我。迁移到2008年?你仍然落后了五年。这就是我们在我们的程序中使用的方式,我在谷歌上搜索过,但没有运气。关于这个问题,我连一点线索都找不到。你能建议我一些步骤来找出这个问题的原因吗。 Java call terminated by uncaught Java exception: java.util.MissingResourceException: Can't find bundle for base name com.microsoft.sqlserver


是因为一些配置问题吗?请建议帮助我。迁移到2008年?你仍然落后了五年。这就是我们在我们的程序中使用的方式,我在谷歌上搜索过,但没有运气。关于这个问题,我连一点线索都找不到。你能建议我一些步骤来找出这个问题的原因吗。
Java call terminated by uncaught Java exception: java.util.MissingResourceException: 
Can't find bundle for base name com.microsoft.sqlserver.jdbc.SQLServerResource, locale en_US

ORA-29532: Java call terminated by uncaught Java exception: java.util.MissingResourceException: 
Can't find bundle for base name com.microsoft.sqlserver.jdbc.SQLServerResource, locale en_US
ORA-06512: at "INTPL.DATASYNC_UTIL", line 8
ORA-06512: at line 1
String password) throws ClassNotFoundException, SQLException
    {
        Connection conn = null;
        switch (dbType)     //M.C
        {
            case DB_ORACLE:
                conn =getRemoteOracleDbConnection (dbURL, user, password);
                break;
            case DB_SQL_SERVER:
                Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");      //sql server 2005
                //Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");    
//sql server 2000

                conn =DriverManager.getConnection(dbURL, user, password);
                break;
        }   

        return conn;
}
package persistence;

import java.sql.*;
import java.util.*;

/**
 * util.DatabaseUtils
 * User: Michael
 * Date: Aug 17, 2010
 * Time: 7:58:02 PM
 */
public class DatabaseUtils {
/*
    private static final String DEFAULT_DRIVER = "oracle.jdbc.driver.OracleDriver";
    private static final String DEFAULT_URL = "jdbc:oracle:thin:@host:1521:database";
    private static final String DEFAULT_USERNAME = "username";
    private static final String DEFAULT_PASSWORD = "password";
*/
/*
    private static final String DEFAULT_DRIVER = "org.postgresql.Driver";
    private static final String DEFAULT_URL = "jdbc:postgresql://localhost:5432/party";
    private static final String DEFAULT_USERNAME = "pgsuper";
    private static final String DEFAULT_PASSWORD = "pgsuper";
*/
    private static final String DEFAULT_DRIVER = "com.mysql.jdbc.Driver";
    private static final String DEFAULT_URL = "jdbc:mysql://localhost:3306/party";
    private static final String DEFAULT_USERNAME = "party";
    private static final String DEFAULT_PASSWORD = "party";

    public static void main(String[] args) {
        long begTime = System.currentTimeMillis();

        String driver = ((args.length > 0) ? args[0] : DEFAULT_DRIVER);
        String url = ((args.length > 1) ? args[1] : DEFAULT_URL);
        String username = ((args.length > 2) ? args[2] : DEFAULT_USERNAME);
        String password = ((args.length > 3) ? args[3] : DEFAULT_PASSWORD);

        Connection connection = null;

        try {
            connection = createConnection(driver, url, username, password);
            DatabaseMetaData meta = connection.getMetaData();
            System.out.println(meta.getDatabaseProductName());
            System.out.println(meta.getDatabaseProductVersion());

            String sqlQuery = "SELECT PERSON_ID, FIRST_NAME, LAST_NAME FROM PERSON ORDER BY LAST_NAME";
            System.out.println("before insert: " + query(connection, sqlQuery, Collections.EMPTY_LIST));

            connection.setAutoCommit(false);
            String sqlUpdate = "INSERT INTO PERSON(FIRST_NAME, LAST_NAME) VALUES(?,?)";
            List parameters = Arrays.asList("Foo", "Bar");
            int numRowsUpdated = update(connection, sqlUpdate, parameters);
            connection.commit();

            System.out.println("# rows inserted: " + numRowsUpdated);
            System.out.println("after insert: " + query(connection, sqlQuery, Collections.EMPTY_LIST));
        } catch (Exception e) {
            rollback(connection);
            e.printStackTrace();
        } finally {
            close(connection);
            long endTime = System.currentTimeMillis();
            System.out.println("wall time: " + (endTime - begTime) + " ms");
        }
    }

    public static Connection createConnection(String driver, String url, String username, String password) throws ClassNotFoundException, SQLException {
        Class.forName(driver);
        if ((username == null) || (password == null) || (username.trim().length() == 0) || (password.trim().length() == 0)) {
            return DriverManager.getConnection(url);
        } else {
            return DriverManager.getConnection(url, username, password);
        }
    }

    public static void close(Connection connection) {
        try {
            if (connection != null) {
                connection.close();
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }


    public static void close(Statement st) {
        try {
            if (st != null) {
                st.close();
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    public static void close(ResultSet rs) {
        try {
            if (rs != null) {
                rs.close();
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    public static void rollback(Connection connection) {
        try {
            if (connection != null) {
                connection.rollback();
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    public static List<Map<String, Object>> map(ResultSet rs) throws SQLException {
        List<Map<String, Object>> results = new ArrayList<Map<String, Object>>();
        try {
            if (rs != null) {
                ResultSetMetaData meta = rs.getMetaData();
                int numColumns = meta.getColumnCount();
                while (rs.next()) {
                    Map<String, Object> row = new HashMap<String, Object>();
                    for (int i = 1; i <= numColumns; ++i) {
                        String name = meta.getColumnName(i);
                        Object value = rs.getObject(i);
                        row.put(name, value);
                    }
                    results.add(row);
                }
            }
        } finally {
            close(rs);
        }
        return results;
    }

    public static List<Map<String, Object>> query(Connection connection, String sql, List<Object> parameters) throws SQLException {
        List<Map<String, Object>> results = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        try {
            ps = connection.prepareStatement(sql);

            int i = 0;
            for (Object parameter : parameters) {
                ps.setObject(++i, parameter);
            }
            rs = ps.executeQuery();
            results = map(rs);
        } finally {
            close(rs);
            close(ps);
        }
        return results;
    }

    public static int update(Connection connection, String sql, List<Object> parameters) throws SQLException {
        int numRowsUpdated = 0;
        PreparedStatement ps = null;
        try {
            ps = connection.prepareStatement(sql);

            int i = 0;
            for (Object parameter : parameters) {
                ps.setObject(++i, parameter);
            }
            numRowsUpdated = ps.executeUpdate();
        } finally {
            close(ps);
        }
        return numRowsUpdated;
    }
}