ITPub博客

首页 > 数据库 > Oracle > 采用java链接timesten内存数据库

采用java链接timesten内存数据库

原创 Oracle 作者:tangyunoracle 时间:2013-12-26 13:26:43 0 删除 编辑
虽然主要是做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-------------------------------------------------

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/24930246/viewspace-1064596/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
有空写写一写,没空看一看。。。 微信号:tangyun0925
  • 博文量
    116
  • 访问量
    1839882