Connecting to Teiid Server - JBoss Community
1. simpleclient/JDBCClient.java を以下のように修正します。
- static Connection getDriverConnection(String vdb) throws Exception {
- //String url = "jdbc:metamatrix:"+vdb+"@../../deploy.properties";
- String url = "jdbc:metamatrix:"+vdb+"@mm://localhost:31000";
- Class.forName("org.teiid.jdbc.TeiidDriver");
- return DriverManager.getConnection(url,"admin", "teiid");
- }
- static Connection getDataSourceConnection(String vdb) throws Exception {
- TeiidDataSource ds = new TeiidDataSource();
- ds.setDatabaseName(vdb);
- ds.setUser("admin");
- ds.setPassword("teiid");
- //ds.setEmbeddedBootstrapFile("../../deploy.properties");
- ds.setServerName("localhost");
- ds.setPortNumber(31000);
- return ds.getConnection();
- }
2. JDBCClient.javaを再コンパイルします。
- javac -classpath ../../client/teiid-6.2.0-client.jar JDBCClient.java
3. Teiid Serverを起動します。
新しいコマンドプロンプトを起動します。
- > cd [Teiid Home]/bin
- > run.bat
- ===============================================================================
- Teiid Bootstrap Environment
- TEIID_HOME: C:\java\teiid-6.2.0
- JAVA: c:\Program Files\java\jdk1.6.0_16\bin\java
- 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
- 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\*;
- ===============================================================================
- Teiid Server started on port = 31000 in 3 Secs
4. run.batを実行します。
- >run.bat admin "select * from groups"
5. 確認の為、Teiid Serverを停止して、run.batがエラーになることを確認します。
Teiid Server を起動したコマンドプロンプトで、Ctrl + C を入力して、終了させます。
run.batを実行します。下記のようなスタックトレースが出力されます。
- Executing using the TeiidDriver
- 2009/09/30 10:58:25 org.teiid.jdbc.SocketProfile connect
- 致命的: Could not create connection
- com.metamatrix.common.comm.exception.SingleInstanceCommunicationException: Error establishing socket to host and port: localhost:31000. Reason: Connection refused: connect
- at com.metamatrix.common.comm.platform.socket.client.SocketServerConnection.selectServerInstance(SocketServerConnection.java:168)
- at com.metamatrix.common.comm.platform.socket.client.SocketServerConnection$ServerConnectionInvocationHandler.getTarget(SocketServerConnection.java:208)
- ・
- ・
- ・