Oracele Timesten串連DSN建立使用者,oraceletimesten

來源:互聯網
上載者:User

Oracele Timesten串連DSN建立使用者,oraceletimesten

1.       啟動開啟

[tt@host2 info]$ ttDaemonAdmin -start -force

/home/tt/TimesTen/tt1122/info/timestend.pid file exists, attempt start due to -force option.

TimesTen Daemon startup OK.

2.       添加測試使用DSN: test_1122

Vi Info/sys.odbc.ini

test_1122=TimesTen 11.2.2 Driver

[test_1122]

Driver=/home/tt/TimesTen/tt1122/lib/libtten.so

DataStore=/home/tt/TimesTen/tt1122/info/DemoDataStore/test_1122

PermSize=40

TempSize=32

PLSQL=1

DatabaseCharacterSet=US7ASCII

3.       串連test_1122

[tt@host2 info]$ ttIsql test_1122

 

Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.

Type ? or "help" for help, type "exit" to quit ttIsql.

4.       建立使用者

Command> create user scott identified by tiger;

 

User created.

 

Command> grant create table to scott;

Command> grant connect to scott;

Command> grant create view to scott;

Command> grant dba to scott;

15111: Invalid privilege: DBA.  Roles are not supported.

The command failed.

5.       給cache group系統管理權限

Command> grant create session,admin,cache_manager to scott;

15140: GRANT failed: User SCOTT already has system privilege CREATE SESSION

The command failed.

Command> grant admin,cache_manager to scott;

connect "DSN=test_1122";

Connection successful: DSN=test_1122;UID=tt;DataStore=/home/tt/TimesTen/tt1122/info/DemoDataStore/test_1122;DatabaseCharacterSet=US7ASCII;ConnectionCharacterSet=US7ASCII;DRIVER=/home/tt/TimesTen/tt1122/lib/libtten.so;PermSize=40;TempSize=32;TypeMode=0;

(Default setting AutoCommit=1)


oracle sql developer 怎不可以串連TimesTen?

連線類型選直接驅動程式,除非你在服務端開啟了server功能
同時確定ODBC裡配的DSN可以串連
 
java遠端連線timesten問題

然後通過如下的程式碼進行訪問

import java.sql.*;
import javax.sql.*;
public class Tttest{
public static void main(String args[])
{
//遠端連線需要的url,程式和TT不在一台伺服器。需要按照上節的方法,提前定義好DSN
String URL = "jdbc:timesten:client:dsn=wzyCS_tt70";
//本地串連需要的url,程式和TT在同一台伺服器
//String URL = "jdbc:timesten:direct:dsn=wzy_tt70";

Connection con = null;
try {
//載入TT的驅動程式
Class.forName("com.timesten.jdbc.TimesTenDriver");
} catch (ClassNotFoundException ex) {ex.printStackTrace();
}
try
{
//獲得串連
con = DriverManager.getConnection(URL);
System.out.println("connected");
//建立jdbc 語句
java.sql.Statement st=con.createStatement();
//執行SQL 查詢操作
java.sql.ResultSet rs=st.executeQuery("select * from test");
while (rs.next())
{
//取出結果集
System.out.println(rs.getString("id"));
}

//關閉串連
con.close();
// Handle any errors
} catch (SQLException ex) {
ex.printStackTrace();}
}
}

如果TT工作正常,DSN定義正常,我們就能看到java程式輸出 結果了。
除了剛開始的url和driver不一樣以外,其他的都是標準的jdbc文法,很簡單,也很強大。

 

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.