问题
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)
Thankyou
回答1:
Code Example:
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 config:
[ODBC Data Sources]
timestendb_11221=TimesTen 11.2.2 Driver
[timestendb_1122]
TTC_SERVER=(Host || IP)
UID=Username
PWD=Password
TTC_SERVER_DSN=Cachedb01
Error: java.sql.SQLException: Problems with loading native library/missing methods: /opt/TimesTen/tt1122/lib/libttJdbcCS.so: libttclient.so: cannot open shared object file: No such file or directory
Resolve:
Check if exists:
$ldd /opt/TimesTen/tt1122/lib/libttJdbcCS.so
Screen:
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)
Check directory timesten client: $ ll /opt/TimesTen/tt1122/lib/libttclient.so
Go to to file to add share lib : sudo vi /etc/ld.so.conf.d/extension.conf
-> Add: /opt/TimesTen/tt1122/lib
Check Again
java -Djava.library.path=/opt/TimesTen/tt1122/lib -jar test1.jar
Code Print:
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
Resolve:
export ODBCINI=/etc/odbc.ini
(if you used odbc driver)export ODBCINI=/var/TimesTen/tt1122/sys.odbc.ini
(if used timesten driver)
Can be add bash file for user:
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)
Result:
$ java -Djava.library.path=/opt/TimesTen/tt1122/lib -jar test1.jar
Code Print:
driverName=com.timesten.jdbc.TimesTenClientDriver
Url=jdbc:timesten:client:dsn=timestendb_1122
classPath=/opt/TimesTen/tt1122/lib
okay
DONE.
来源:https://stackoverflow.com/questions/19949407/what-about-problems-with-loading-native-library-missing-methods-libttjdbc-so-l