2009年9月30日水曜日

[Teiid] exampleを動かしてみる (2) Bookmark and Share

次に simpleclient を "Server" mode に変更してみます。

Connecting to Teiid Server - JBoss Community

1. simpleclient/JDBCClient.java を以下のように修正します。
  1. static Connection getDriverConnection(String vdb) throws Exception {  
  2.   //String url = "jdbc:metamatrix:"+vdb+"@../../deploy.properties";  
  3.   String url = "jdbc:metamatrix:"+vdb+"@mm://localhost:31000";  
  4.   Class.forName("org.teiid.jdbc.TeiidDriver");  
  5.   
  6.   return DriverManager.getConnection(url,"admin""teiid");    
  7. }  
  1. static Connection getDataSourceConnection(String vdb) throws Exception {  
  2.   TeiidDataSource ds = new TeiidDataSource();  
  3.   ds.setDatabaseName(vdb);  
  4.   ds.setUser("admin");  
  5.   ds.setPassword("teiid");  
  6.   //ds.setEmbeddedBootstrapFile("../../deploy.properties");  
  7.   ds.setServerName("localhost");  
  8.   ds.setPortNumber(31000);  
  9.   
  10.   return ds.getConnection();  
  11. }  

2. JDBCClient.javaを再コンパイルします。
  1. javac -classpath ../../client/teiid-6.2.0-client.jar JDBCClient.java  

3. Teiid Serverを起動します。
 新しいコマンドプロンプトを起動します。
  1. > cd [Teiid Home]/bin  
  2. > run.bat  
  3. ===============================================================================  
  4.   
  5.   Teiid Bootstrap Environment  
  6.   
  7.   TEIID_HOME: C:\java\teiid-6.2.0  
  8.   
  9.   JAVA: c:\Program Files\java\jdk1.6.0_16\bin\java  
  10.   
  11.   JAVA_OPTS:  -Xms128m -Xmx512m -XX:MaxPermSize=256m -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9999 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Dteiid.home=C:\java\teiid-6.2.0  
  12.   
  13.   CLASSPATH: C:\java\teiid-6.2.0\lib\patches\*;C:\java\teiid-6.2.0\deploy;C:\java\teiid-6.2.0\client\*;C:\java\teiid-6.2.0\lib\*;  
  14.   
  15. ===============================================================================  
  16.   
  17. Teiid Server started on port = 31000 in 3 Secs  

4. run.batを実行します。
  1. >run.bat admin "select * from groups"  
前回と同様の結果となれば成功です。

5. 確認の為、Teiid Serverを停止して、run.batがエラーになることを確認します。
 Teiid Server を起動したコマンドプロンプトで、Ctrl + C を入力して、終了させます。
 run.batを実行します。下記のようなスタックトレースが出力されます。
  1. Executing using the TeiidDriver  
  2. 2009/09/30 10:58:25 org.teiid.jdbc.SocketProfile connect  
  3. 致命的: Could not create connection  
  4. com.metamatrix.common.comm.exception.SingleInstanceCommunicationException: Error establishing socket to host and port: localhost:31000. Reason: Connection refused: connect  
  5.         at com.metamatrix.common.comm.platform.socket.client.SocketServerConnection.selectServerInstance(SocketServerConnection.java:168)  
  6.         at com.metamatrix.common.comm.platform.socket.client.SocketServerConnection$ServerConnectionInvocationHandler.getTarget(SocketServerConnection.java:208)  
  7. ・  
  8. ・  
  9. ・  

0 件のコメント: