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

Uwe Schindler commented on SOLR-7986:
-------------------------------------

Same as adding codecs to Lucene. Just create META-INF/services folder inside 
resources and add a file named with the abstract Driver class (java.sql.Driver 
- in Lucene its similar: org.apache.lucene.codecs.Codec as filename). Inside 
the file add the License header using # line prefix plus a single line with the 
implementation class: org.apache.solr.client.solrj.io.sql.DriverImpl). This 
file must of course be added to the solrj.jar file. 

I can do that for you. I will post a separate patch. Once you have done this, 
you can remove the following line from the docs and possible tests:

{code:java}
Class.forName("org.apache.solr.client.solrj.io.sql.DriverImpl").newInstance();
{code}

This is no longer needed then. If you call DriverManager.getConnection(), the 
SPI framework behind the SQL infratsructure scans classpath for *all* 
META-INF/services/java.sql.Driver files and loads the classes inside as 
instances and register them as Driver. Afterwards it can resolve the connection 
URI.

> JDBC Driver for SQL Interface
> -----------------------------
>
>                 Key: SOLR-7986
>                 URL: https://issues.apache.org/jira/browse/SOLR-7986
>             Project: Solr
>          Issue Type: New Feature
>          Components: clients - java
>    Affects Versions: Trunk
>            Reporter: Joel Bernstein
>         Attachments: SOLR-7986.patch, SOLR-7986.patch, SOLR-7986.patch, 
> SOLR-7986.patch, SOLR-7986.patch, SOLR-7986.patch, SOLR-7986.patch
>
>
> This ticket is to create a JDBC Driver (thin client) for the new SQL 
> interface (SOLR-7560). As part of this ticket a driver will be added to the 
> Solrj libary under the package: *org.apache.solr.client.solrj.io.sql*
> Initial implementation will include basic *Driver*, *Connection*, *Statement* 
> and *ResultSet* implementations.
> Future releases can build on this implementation to support a wide range of 
> JDBC clients and tools.
> *Syntax using parallel Map/Reduce for aggregations*:
> {code}
> Properties props = new Properties();
> props.put("aggregationMode", "map_reduce");
> props.put("numWorkers", "10");
> Class.forName("org.apache.solr.client.solrj.io.sql.DriverImpl").newInstance();
> Connection con = 
> DriverManager.getConnection("jdbc:solr://<zkhost:port>?collection=<collection>",
>  props);
> Statement stmt = con.createStatement();
> ResultSet rs = stmt.executeQuery("select a, sum(b) from tablex group by a 
> having sum(b) > 100");
> while(rs.next()) {
>     String a = rs.getString("a");
>     double sumB = rs.getDouble("sum(b)");
> }
> {code} 
> *Syntax using JSON facet API for aggregations*:
> {code}
> Properties props = new Properties();
> props.put("aggregationMode", "facet");
> Class.forName("org.apache.solr.client.solrj.io.sql.DriverImpl").newInstance();
> Connection con = 
> DriverManager.getConnection("jdbc:solr://<zkhost:port>?collection=<collection>",
>  props);
> Statement stmt = con.createStatement();
> ResultSet rs = stmt.executeQuery("select a, sum(b) from tablex group by a 
> having sum(b) > 100");
> while(rs.next()) {
>     String a = rs.getString("a");
>     double sumB = rs.getDouble("sum(b)");
> }
> {code}
>  



--
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

Reply via email to