加载本机库/缺少方法的问题如何:libttJdbc.so,libtten.so


java.sql.SQLException: Problems with loading native library/missing methods: /home/timesten/TimesTen/tt1122/lib/libttJdbc.so: libtten.so: cannot open shared object file: No such file or directory
    at com.timesten.jdbc.JdbcOdbcConnection.connect(JdbcOdbcConnection.java:1794)
    at com.timesten.jdbc.TimesTenDriver.connect(TimesTenDriver.java:305)
    at com.timesten.jdbc.TimesTenDriver.connect(TimesTenDriver.java:161)
    at java.sql.DriverManager.getConnection(DriverManager.java:620)
    at java.sql.DriverManager.getConnection(DriverManager.java:222)
    at Test.main(Test.java:15)

谢谢

代码示例:

try{        
     String driverName =  "com.timesten.jdbc.TimesTenClientDriver"; // "sun.jdbc.odbc.JdbcOdbcDriver"
      String Url = "jdbc:timesten:client:dsn=timestendb_1122"; //"jdbc:odbc:timestendb_1122";   
       if(args.length >= 2){
                 driverName = args[0]; 
                 Url = args[1];
        }           
        System.out.println("driverName=" + driverName);
        System.out.println("Url=" + Url);
        System.out.println("classPath=" + System.getProperty("java.library.path"));     
            Class.forName(driverName).newInstance();
              // Open a connection to TimesTen
            Connection conn = DriverManager.getConnection(Url);        
            if(conn != null){
                System.out.println("okay");
            }
            else{
                 System.out.println("fail");
            }
                conn.close();
} catch (SQLException e) {
        e.printStackTrace();
}

ODBC .ini 配置:

[ODBC Data Sources]
timestendb_11221=TimesTen 11.2.2 Driver
[timestendb_1122]
TTC_SERVER=(Host || IP)
UID=Username
PWD=Password
TTC_SERVER_DSN=Cachedb01

错误:java.sql.SQLException:加载本机时出现问题 library/missing methods:/opt/TimesTen/tt1122/lib/libttJdbcCS.so: libttclient.so:无法打开共享对象文件:没有此类文件或 目录

解决:

检查是否存在:

$ldd /opt/TimesTen/tt1122/lib/libttJdbcCS.so

屏幕:

linux-vdso.so.1 =>  (0x00007fff039b4000)
    libttclient.so => not found
    libttco.so => not found
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f57d642e000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f57d6218000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f57d5e58000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f57d5c53000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f57d6876000)

检查目录时间客户端:$ ll /opt/TimesTen/tt1122/lib/libttclient.so

转到文件以添加共享库:sudo vi /etc/ld.so.conf.d/extension.conf -> 添加:/opt/TimesTen/tt1122/lib

再次检查

java -Djava.library.path=/opt/TimesTen/tt1122/lib -jar test1.jar 

代码打印:

driverName=com.timesten.jdbc.TimesTenClientDriver
Url=jdbc:timesten:client:dsn=timestendb_1122
classPath=/opt/TimesTen/tt1122/lib
java.sql.SQLException: [TimesTen][TimesTen 11.2.2.5.0 CLIENT]Cannot find the requested DSN (timestendb_1122) in ODBCINI, Unable to open /var/TimesTen/tt1122/sys.odbc.ini. Permission denied

解决:

  1. export ODBCINI=/etc/odbc.ini(如果您使用了 ODBC 驱动程序)
  2. export ODBCINI=/var/TimesTen/tt1122/sys.odbc.ini(如果使用时间十驱动程序)

可以为用户添加bash文件:

nano /home/nhatvd/.bashrc 
export ODBCINI=/etc/odbc.ini
$ ldd /opt/TimesTen/tt1122/lib/libttJdbcCS.so
    linux-vdso.so.1 =>  (0x00007fff429fe000)
    libttclient.so => /opt/TimesTen/tt1122/lib/libttclient.so (0x00007fd7977ee000)
    libttco.so => /opt/TimesTen/tt1122/lib/libttco.so (0x00007fd797520000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fd797223000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fd79700d000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd796c4d000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fd796a48000)
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fd796748000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fd79652b000)
    libnsl.so.1 => /lib/x86_64-linux-gnu/libnsl.so.1 (0x00007fd796310000)
    /lib64/ld-linux-x86-64.so.2 (0x00007fd797b12000)

结果:

$ java -Djava.library.path=/opt/TimesTen/tt1122/lib -jar test1.jar 

代码打印:

driverName=com.timesten.jdbc.TimesTenClientDriver
Url=jdbc:timesten:client:dsn=timestendb_1122
classPath=/opt/TimesTen/tt1122/lib

做。

相关内容

  • 没有找到相关文章

最新更新