Hey,
I want to use JDBC to connect kdb.
1?Get jdbc.jar from http://code.kx.com/wsvn/code/kx/kdb%2B/c/?#a552c86fafdfd8cdfec7d5d6b5522f347
2?According to this article, I wrote the following code to have a test.
http://code.kx.com/wiki/Cookbook/InterfacingWithJava#Is_there_a_JDBC_interface.3F
3?Start q at port 5001
But, throw the error No suitable driver found for jdbc:q:127.0.0.1:5001
at this line: con = DriverManager.getConnection(“jdbc:apache:commons:dbcp:q”);
I can not find the reason, need help.
Thanks,
Roy
--------------------CODE-------------------------
importjava.sql.Connection;importjava.sql.DriverManager;importjava.sql.SQLException; importorg.apache.commons.dbcp.ConnectionFactory;importorg.apache.commons.dbcp.DriverManagerConnectionFactory;importorg.apache.commons.dbcp.PoolableConnectionFactory;importorg.apache.commons.dbcp.PoolingDriver;importorg.apache.commons.pool.ObjectPool;importorg.apache.commons.pool.impl.GenericObjectPool; publicclassTestJdbc{publicTestJdbc(){ ObjectPool connectionPool=newGenericObjectPool(null);ConnectionFactory connectionFactory=newDriverManagerConnectionFactory("jdbc:q:[127.0.0.1:5001]("http://127.0.0.1:5001")",null); PoolableConnectionFactory poolableConnectionFactory=newPoolableConnectionFactory(connectionFactory, connectionPool,null,null,false,true); try{Class.forName("org.apache.commons.dbcp.PoolingDriver");}catch(ClassNotFoundExceptione){e.printStackTrace();} PoolingDriver driver=null;try{driver=(PoolingDriver)DriverManager.getDriver("jdbc:apache:commons:dbcp:");}catch(SQLExceptione){e.printStackTrace();}driver.registerPool("q", connectionPool);} publicConnectiongetConnection(){Connectioncon=null;try{con=DriverManager.getConnection("jdbc:apache:commons:dbcp:q");}catch(SQLExceptione){thrownewRuntimeException(e);}returncon;} publicstaticvoidmain(String[]args){TestJdbc t=newTestJdbc();Connectionconn=t.getConnection(); } }