You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by 郝加来 <ha...@neusoft.com> on 2016/01/09 14:42:56 UTC

how to use jdbc

 各位好:

    如何使用 Jdbc 访问缓存里的对象数据?
   // Register JDBC driver.
Class.forName("org.apache.ignite.IgniteJdbcDriver");
// Open JDBC connection (cache name is not specified, which means that we use default cache).
Connection conn = DriverManager.getConnection("jdbc:ignite:cfg://file://D:\\haojlprojects\\HelloIgnite\\src\\ignite-jdbc.xml");
// Query names of all people.
ResultSet rs = conn.createStatement().executeQuery("select * from Person");
while (rs.next()) {
String name = rs.getString(1);
System.out.println(name);
}

now the error is :

java.sql.SQLException: Failed to start Ignite node.
at org.apache.ignite.internal.jdbc2.JdbcConnection.<init>(JdbcConnection.java:152)
1、count:
at org.apache.ignite.IgniteJdbcDriver.connect(IgniteJdbcDriver.java:350)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at testMain.testjdbc(testMain.java:33)
at testMain.main(testMain.java:203)
Caused by: class org.apache.ignite.IgniteCheckedException: Failed to instantiate Spring XML application context [springUrl=file://D:/haojlprojects/HelloIgnite/src/ignite-jdbc.xml, err=IOException parsing XML document from URL [file://D:/haojlprojects/HelloIgnite/src/ignite-jdbc.xml]; nested exception is java.net.UnknownHostException: D]
at org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl.applicationContext(IgniteSpringHelperImpl.java:391)
at org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl.loadConfigurations(IgniteSpringHelperImpl.java:104)
at org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl.loadConfigurations(IgniteSpringHelperImpl.java:98)
at org.apache.ignite.internal.IgnitionEx.loadConfigurations(IgnitionEx.java:604)
at org.apache.ignite.internal.IgnitionEx.loadConfigurations(IgnitionEx.java:643)
at org.apache.ignite.internal.jdbc2.JdbcConnection.loadConfiguration(JdbcConnection.java:196)
at org.apache.ignite.internal.jdbc2.JdbcConnection.getIgnite(JdbcConnection.java:172)
at org.apache.ignite.internal.jdbc2.JdbcConnection.<init>(JdbcConnection.java:141)
... 5 more
 
以上
谢谢


 
郝加来
 
金融华东事业部

东软集团股份有限公司
上海市闵行区紫月路1000号东软软件园
Postcode:200241
Tel:(86 21) 33578591
Fax:(86 21) 23025565-111
Mobile:13764970711
Email:haojl@neusoft.com
Http://www.neusoft.com
 
 
 
 
 


---------------------------------------------------------------------------------------------------
Confidentiality Notice: The information contained in this e-mail and any accompanying attachment(s)
is intended only for the use of the intended recipient and may be confidential and/or privileged of
Neusoft Corporation, its subsidiaries and/or its affiliates. If any reader of this communication is
not the intended recipient, unauthorized use, forwarding, printing,  storing, disclosure or copying
is strictly prohibited, and may be unlawful.If you have received this communication in error,please
immediately notify the sender by return e-mail, and delete the original message and all copies from
your system. Thank you.
---------------------------------------------------------------------------------------------------

Re: how to use jdbc

Posted by Denis Magda <dm...@gridgain.com>.
Hi,

The path to the configuration file  must contain three slashes 
"file:*///"*. You have only two slashes for now and this is the reason 
of the exception.

Also please don't forget to start a server node that will create and 
populate a cache with 'Person' objects before.

Feel free to ask if you have more questions.

Regards,
Denis

On 1/9/2016 4:42 PM, 郝加来 wrote:
>  各位好:
>
>     如何使用 Jdbc 访问缓存里的对象数据?
> // Register JDBC driver.
> Class.forName("org.apache.ignite.IgniteJdbcDriver");
> // Open JDBC connection (cache name is not specified, which means that we use default cache).
> Connection conn = DriverManager.getConnection("jdbc:ignite:cfg://file://D:\\haojlprojects\\HelloIgnite\\src\\ignite-jdbc.xml");
> // Query names of all people.
> ResultSet rs = conn.createStatement().executeQuery("select * from Person");
> while (rs.next()) {
> String name = rs.getString(1);
> System.out.println(name);
> }
>
> now the error is :
>
> java.sql.SQLException: Failed to start Ignite node.
> at org.apache.ignite.internal.jdbc2.JdbcConnection.<init>(JdbcConnection.java:152)
> 1、count:
> at org.apache.ignite.IgniteJdbcDriver.connect(IgniteJdbcDriver.java:350)
> at java.sql.DriverManager.getConnection(Unknown Source)
> at java.sql.DriverManager.getConnection(Unknown Source)
> at testMain.testjdbc(testMain.java:33)
> at testMain.main(testMain.java:203)
> Caused by: class org.apache.ignite.IgniteCheckedException: Failed to instantiate Spring XML application context [springUrl=file://D:/haojlprojects/HelloIgnite/src/ignite-jdbc.xml, err=IOException parsing XML document from URL [file://D:/haojlprojects/HelloIgnite/src/ignite-jdbc.xml]; nested exception is java.net.UnknownHostException: D]
> at org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl.applicationContext(IgniteSpringHelperImpl.java:391)
> at org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl.loadConfigurations(IgniteSpringHelperImpl.java:104)
> at org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl.loadConfigurations(IgniteSpringHelperImpl.java:98)
> at org.apache.ignite.internal.IgnitionEx.loadConfigurations(IgnitionEx.java:604)
> at org.apache.ignite.internal.IgnitionEx.loadConfigurations(IgnitionEx.java:643)
> at org.apache.ignite.internal.jdbc2.JdbcConnection.loadConfiguration(JdbcConnection.java:196)
> at org.apache.ignite.internal.jdbc2.JdbcConnection.getIgnite(JdbcConnection.java:172)
> at org.apache.ignite.internal.jdbc2.JdbcConnection.<init>(JdbcConnection.java:141)
> ... 5 more
> 以上
> 谢谢
> ------------------------------------------------------------------------
> *郝加来*
> 金融华东事业部
>
> 东软集团股份有限公司
> 上海市闵行区紫月路1000号东软软件园
> Postcode:200241
> Tel:(86 21) 33578591
> Fax:(86 21) *23025565-111*
> Mobile:13764970711
> Email:haojl@neusoft.com <ma...@neusoft.com>
> Http://www.neusoft.com <http://www.neusoft.com/>
>
> ---------------------------------------------------------------------------------------------------
> Confidentiality Notice: The information contained in this e-mail and 
> any accompanying attachment(s)
> is intended only for the use of the intended recipient and may be 
> confidential and/or privileged of
> Neusoft Corporation, its subsidiaries and/or its affiliates. If any 
> reader of this communication is
> not the intended recipient, unauthorized use, forwarding, printing,  
> storing, disclosure or copying
> is strictly prohibited, and may be unlawful.If you have received this 
> communication in error,please
> immediately notify the sender by return e-mail, and delete the 
> original message and all copies from
> your system. Thank you.
> ---------------------------------------------------------------------------------------------------
>


Re: how to use jdbc

Posted by vinshar <vi...@gmail.com>.
Didn't knew that. Thanks for the link.



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/how-to-use-jdbc-tp2457p2474.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: how to use jdbc

Posted by Denis Magda <dm...@gridgain.com>.
Vinay,

It's possible to query data from an Ignite cache using JDBC API [1]. 
That was a topic of the question.

[1] https://apacheignite.readme.io/docs/jdbc-driver

--
Denis

On 1/9/2016 8:42 PM, vinshar wrote:
> What are you trying to do here by passing ignite configuration xml path in
> JDBC Connection String?
>
>
>
> --
> View this message in context: http://apache-ignite-users.70518.x6.nabble.com/how-to-use-jdbc-tp2457p2463.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.


Re: how to use jdbc

Posted by vinshar <vi...@gmail.com>.
What are you trying to do here by passing ignite configuration xml path in
JDBC Connection String? 



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/how-to-use-jdbc-tp2457p2463.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.