You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Kevin Risden (JIRA)" <ji...@apache.org> on 2016/04/20 18:16:25 UTC
[jira] [Comment Edited] (SOLR-9018) SolrJ JDBC - Jython
Documentation
[ https://issues.apache.org/jira/browse/SOLR-9018?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15250169#comment-15250169 ]
Kevin Risden edited comment on SOLR-9018 at 4/20/16 4:15 PM:
-------------------------------------------------------------
Jython native example script:
{code}
#!/usr/bin/env jython
# http://www.jython.org/jythonbook/en/1.0/DatabasesAndJython.html
# https://wiki.python.org/jython/DatabaseExamples#SQLite_using_JDBC
import sys
from java.lang import Class
from java.sql import DriverManager, SQLException
if __name__ == '__main__':
jdbc_url = "jdbc:solr://solr:9983?collection=test"
driverName = "org.apache.solr.client.solrj.io.sql.DriverImpl"
statement = "select fielda, fieldb, fieldc, fieldd_s, fielde_i from test limit 10"
dbConn = DriverManager.getConnection(jdbc_url)
stmt = dbConn.createStatement()
resultSet = stmt.executeQuery(statement)
while resultSet.next():
print(resultSet.getString("fielda"))
resultSet.close()
stmt.close()
dbConn.close()
sys.exit(0)
{code}
was (Author: risdenk):
Jython Native Connection example script:
{code}
#!/usr/bin/env jython
# http://www.jython.org/jythonbook/en/1.0/DatabasesAndJython.html
# https://wiki.python.org/jython/DatabaseExamples#SQLite_using_JDBC
import sys
from java.lang import Class
from java.sql import DriverManager, SQLException
if __name__ == '__main__':
jdbc_url = "jdbc:solr://solr:9983?collection=test"
driverName = "org.apache.solr.client.solrj.io.sql.DriverImpl"
statement = "select fielda, fieldb, fieldc, fieldd_s, fielde_i from test limit 10"
dbConn = DriverManager.getConnection(jdbc_url)
stmt = dbConn.createStatement()
resultSet = stmt.executeQuery(statement)
while resultSet.next():
print(resultSet.getString("fielda"))
resultSet.close()
stmt.close()
dbConn.close()
sys.exit(0)
{code}
> SolrJ JDBC - Jython Documentation
> ---------------------------------
>
> Key: SOLR-9018
> URL: https://issues.apache.org/jira/browse/SOLR-9018
> Project: Solr
> Issue Type: Sub-task
> Components: SolrJ
> Reporter: Kevin Risden
>
> Jython integrates both Python and Java. This makes connecting to JDBC possible.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org