采用java链接timesten内存数据库

虽然主要是做TT的维保,但是由于TT使用的人相对少,很少相关的资料,就两java如何连接TT都很难找到,这里从官方文档中摘抄一段,做下记录备查。
##Write the below program in a file MyConnectionTest.java using vi or your favorite text editor.
#MyConnectionTest.java
import java.sql.*;

class MyConnectionTest {

  /* This is DSN that we specify in odbc.ini file */
  static String dsnname = "myjdbctest";

  /* URL to connect to the datastore, that contains the standard prefix and dsnname */
  static String url = "jdbc:timesten:direct:" + dsnname;

  public static void main (String args[])
  {
    /* Try to load the driver first */
    try {
    Class.forName("com.timesten.jdbc.TimesTenDriver");
    } catch (ClassNotFoundException ex) {
    System.out.println ("Failed to load the driver");
    ex.printStackTrace();
   }

   /* Try to get the connecction to TimesTen datastore and close it*/
   try {
   Connection con = DriverManager.getConnection(url);
   System.out.println ("Connection Success");
   con.close();
   } catch (SQLException ex) {
   System.out.println ("Failed to connect/disconnect to TimesTen datastore");
   ex.printStackTrace();
   }

}



编译:
javac MyConnectionTest.java
执行:
java MyConnectionTest

----------------------------End-------------------------------------------------
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值