要安裝好timesten
需要配好system dsn ttdemo
創建表和存儲過程
以上略
java內容如下
package com;
import javasqlConnection;
import javasqlPreparedStatement;
import javasqlDriverManager;
import javasqlResultSet;
import javasqlStatement;
import javaxsqlrowset*;
import comsunrowsetCachedRowSetImpl;
import comtimestenjdbcTimesTenDataSource;
public class Test {
public static void main(String arg[]) {
try {
//ClassforName(oraclejdbcdriverOracleDriver);
ClassforName(comtimestenjdbcTimesTenDriver);
String url = jdbc:timesten:direct:dsn=ttdemo;uid=logstat;pwd=logstat;ORACLEID=logstat_;OraclePWD=logstat;
TimesTenDataSource ds = new TimesTenDataSource();
dssetUrl(url);
Connection con = dsgetConnection();
consetAutoCommit(false);
PreparedStatement pstmt = null;
String sql = {call p_insert(??)};
pstmt = conprepareCall(sql);
pstmtsetInt();
pstmtsetString( Test timesten using procerure!);
pstmtexecuteUpdate();
mit();
consetAutoCommit(true);
conclose();
} catch (Exception e) {
Systemoutprintln(etoString());
}
}
}
備注在使用timesten實現文章提到的批量入庫就會出現錯誤
javalangClassCastException: comtimestenjdbcJdbcOdbcConnection
at oraclesqlArrayDescriptorcreateDescriptor(ArrayDescriptorjava:)
at oraclesqlArrayDescriptorcreateDescriptor(ArrayDescriptorjava:)
at comTestmain(Testjava:)
由於java水平太差不好解決記錄於此
From:http://tw.wingwit.com/Article/program/Java/hx/201311/26411.html