[ 
https://issues.apache.org/jira/browse/SOLR-9018?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15250169#comment-15250169
 ] 

Kevin Risden commented on SOLR-9018:
------------------------------------

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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to