没有为jdcb找到合适的驱动程序

时间:2016-03-29 19:06:37

标签: java sql oracle

这是我第一次使用Java进行sql工作,我所做的只是创建一个简单的程序来打开和关闭连接

package exercises;

import java.sql.*;

public class JdbcEx1 {
    static Connection conn = null;
    static String dbURL = "jdbc:oracle:thin:@127.0.0.1:1521:XE";
    static String user = "labs";
    static String password = "labs";

    public JdbcEx1() {}

    public static void main (String args[]) throws SQLException {

        try{
            Class.forName("oracle.jdbc.driver.OracleDriver");
        } catch (ClassNotFoundException e){
            System.err.println(e.getMessage());
        }

        try {
            conn = DriverManager.getConnection(dbURL, user, password);
            conn.clearWarnings();
            System.out.println("Connection opened! for driver ==>Oracle 11XE");
        } catch (SQLException e) {
            System.err.println(e.getMessage());
        } finally {
            if(!conn.isClosed()) {
                conn.close();
                System.out.println("Connection Close! Oracle");
            }
        }

    }
}

每当我尝试运行它时,我都会收到以下错误:

oracle.jdbc.driver.OracleDriver 没有为jdbc找到合适的驱动程序:oracle:thin:@ 127.0.0.1:1521:XE

我真的不知道最近会发生什么,我已经尝试多次使用调试器来运行它,但这让我更加困惑

1 个答案:

答案 0 :(得分:1)

您指出的import numpy as np from numba import jit from timeit import timeit def find_first(x): idx, step = 0, 32 while idx < x.size: nz, = x[idx: idx + step].nonzero() if len(nz): return nz[0] + idx idx += step step = min(9600, step + step // 2) return -1 @jit(nopython=True) def find_first_numba(vec): """return the index of the first occurence of item in vec""" for i in range(len(vec)): if vec[i]: return i return -1 SIZE = 10_000_000 # First only x = np.empty(SIZE) find_first_numba(x[:10]) print('---- FIRST ----') x[:] = 0 x[0] = 1 print('ndarray.nonzero', timeit(lambda: x.nonzero()[0][0], number=100)*10, 'ms') print('find_first', timeit(lambda: find_first(x), number=1000), 'ms') print('find_first_numba', timeit(lambda: find_first_numba(x), number=1000), 'ms') print('---- LAST ----') x[:] = 0 x[-1] = 1 print('ndarray.nonzero', timeit(lambda: x.nonzero()[0][0], number=100)*10, 'ms') print('find_first', timeit(lambda: find_first(x), number=100)*10, 'ms') print('find_first_numba', timeit(lambda: find_first_numba(x), number=100)*10, 'ms') print('---- NONE ----') x[:] = 0 print('ndarray.nonzero', timeit(lambda: x.nonzero()[0], number=100)*10, 'ms') print('find_first', timeit(lambda: find_first(x), number=100)*10, 'ms') print('find_first_numba', timeit(lambda: find_first_numba(x), number=100)*10, 'ms') print('---- ALL ----') x[:] = 1 print('ndarray.nonzero', timeit(lambda: x.nonzero()[0][0], number=100)*10, 'ms') print('find_first', timeit(lambda: find_first(x), number=100)*10, 'ms') print('find_first_numba', timeit(lambda: find_first_numba(x), number=100)*10, 'ms') 文件的路径:

---- FIRST ---- ndarray.nonzero 54.733994480002366 ms find_first 0.0013148509997336078 ms find_first_numba 0.0002839310000126716 ms ---- LAST ---- ndarray.nonzero 54.56336712999928 ms find_first 25.38929685000312 ms find_first_numba 8.022820680002951 ms ---- NONE ---- ndarray.nonzero 24.13432420999925 ms find_first 25.345200140000088 ms find_first_numba 8.154927100003988 ms ---- ALL ---- ndarray.nonzero 55.753537260002304 ms find_first 0.0014760300018679118 ms find_first_numba 0.0004358099977253005 ms

必须在环境变量ndarray.nonzero中指定。

  

您需要在类路径环境变量中包含ojdbc6.jar   为了获得JDBC 4.0标准支持。