无论是操作本地的还是远程的TimesTen服务,客户端都需要安装Tiems Client,并配置客户端DSN。
基本信息如下:
1:创建客户端DSN
点击“添加”:
双击“TimesTen Client 11.2.2”.
配置server信息
输入Server Name,Network Address,Network Port等信息。
2:客户端JDBC测试
package tt_test01; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.util.logging.Level; import java.util.logging.Logger; /** * @author yan * @date * @version V1.0 * @desc */ public class Tt_test01 { /** * @param args */ public static void main(String[] args) { //连接本地timesten String URL = "jdbc:timesten:client:dsn=loctest;UID=test;PWD=test"; Connection conn = null; try { Class.forName("com.timesten.jdbc.ObservableConnectionDS"); conn = DriverManager.getConnection(URL); System.out.println("===conn:"+conn); } catch (ClassNotFoundException ex) { Logger.getLogger(Tt_test01.class.getName()).log(Level.SEVERE, null, ex); } catch (SQLException ex) { Logger.getLogger(Tt_test01.class.getName()).log(Level.SEVERE, null, ex); } finally{ try { if(null!=conn){ conn.close(); } } catch (SQLException ex) { Logger.getLogger(Tt_test01.class.getName()).log(Level.SEVERE, null, ex); } } } }
final String tt_url = "jdbc:timesten:client:dsn=nssb_1122_cs;UID=test;PWD=test"; TimesTenDataSource ttds = new TimesTenDataSource(); ttds.setUrl(tt_url); TimesTenConnection ttcon = (TimesTenConnection) ttds.getConnection(); System.out.println("====>ttcon:"+ttcon); final String sql = "insert into t01(nsrsbh,msg) values(?,?)"; PreparedStatement ps = ttcon.prepareStatement(sql); ps.setString(1, nsrxx.getNsrsbh()); ps.setString(2, nsrxx.getMsg()); int flag = ps.executeUpdate(); System.out.println("===>flag:"+flag); ps.close(); ttcon.close();