[jira] [Commented] (SOLR-9018) SolrJ JDBC - Jython Documentation

2016-04-20 Thread Kevin Risden (JIRA)

[ 
https://issues.apache.org/jira/browse/SOLR-9018?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=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: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[jira] [Commented] (SOLR-9018) SolrJ JDBC - Jython Documentation

2016-04-20 Thread Kevin Risden (JIRA)

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

Kevin Risden commented on SOLR-9018:


Jython zxJDBC 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_ziclix

import sys

from com.ziclix.python.sql import zxJDBC

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"

  with zxJDBC.connect(jdbc_url, None, None, driverName) as conn:
with conn:
  with conn.cursor() as c:
c.execute(statement)
print(c.fetchall())

  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-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org



[jira] [Commented] (SOLR-9018) SolrJ JDBC - Jython Documentation

2016-04-20 Thread Kevin Risden (JIRA)

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

Kevin Risden commented on SOLR-9018:


Requires that CLASSPATH environment variable be set to the SolrJ jars before 
running the Jython scripts.

> 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-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org