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

Uwe Schindler edited comment on SOLR-7986 at 9/11/15 6:45 PM:
--------------------------------------------------------------

Most drivers I have seen (e.g. Sybase, Oracle) do both. Inside static 
initialization, so Java 5 code that does not do SPI can still load it (does not 
affect us, because we require minimum Java 7). Java 7+ for sure always loads 
via SPI. It may only fail when you have fckd up your classloaders, because it 
checks context class loader.

So I would do both: Add the SPI control file and also add the register call to 
{{static { }}} block. The people can fall back to simple class.forName()

Example mysql: This is static init for legacy users with Java 5: 
http://grepcode.com/file/repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.35/com/mysql/jdbc/Driver.java#47

The MySQL driver currently has no META-INF because it is still on Java 5.


was (Author: thetaphi):
Most drivers I have seen (e.g. mysql) do both. Inside static initialization, so 
Java 5 code that does not do SPI can still load it (does not affect us, because 
we require minimum Java 7). Java 7+ for sure always loads via SPI. It may only 
fail when you have fckd up your classloaders, because it checks context class 
loader.

So I would do both: Add the SPI control file and also add the register call to 
{{static { }}} block. The people can fall back to simple class.forName()

Example mysql: This is static init for legacy users with Java 5: 
http://grepcode.com/file/repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.35/com/mysql/jdbc/Driver.java#47

The MySQL driver currently has no META-INF because it is still on Java 5.

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

Reply via email to