Skip to content

Commit

Permalink
[CALCITE-1700] De-couple the HsqldbServer into a generic JDBC server
Browse files Browse the repository at this point in the history
We can provide a lot more value by just providing a standalone
process which can use *any* JDBC driver instead of hard-coding
it to be HSQLDB only.

Closes apache#404
  • Loading branch information
joshelser committed Mar 19, 2017
1 parent 554d963 commit 8bac70e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,31 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.calcite.avatica.hsqldb;
package org.apache.calcite.avatica.server;

import org.apache.calcite.avatica.jdbc.JdbcMeta;
import org.apache.calcite.avatica.remote.Driver.Serialization;
import org.apache.calcite.avatica.remote.LocalService;
import org.apache.calcite.avatica.server.HttpServer;
import org.apache.calcite.avatica.util.Unsafe;

import com.beust.jcommander.IStringConverter;
import com.beust.jcommander.JCommander;
import com.beust.jcommander.Parameter;

import net.hydromatic.scott.data.hsqldb.ScottHsqldb;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Locale;

/**
* An Avatica server for HSQLDB.
* An Avatica server for arbitrary JDBC drivers.
*/
public class HsqldbServer {
private static final Logger LOG = LoggerFactory.getLogger(HsqldbServer.class);
public class StandaloneServer {
private static final Logger LOG = LoggerFactory.getLogger(StandaloneServer.class);

@Parameter(names = { "-u", "--url" }, required = true,
description = "JDBC driver url for the server")
private String url;

@Parameter(names = { "-p", "--port" }, required = false,
description = "Port the server should bind")
Expand All @@ -57,8 +58,7 @@ public void start() {
}

try {
// Set up Julian's ScottDB for HSQLDB
JdbcMeta meta = new JdbcMeta(ScottHsqldb.URI, ScottHsqldb.USER, ScottHsqldb.PASSWORD);
JdbcMeta meta = new JdbcMeta(url);
LocalService service = new LocalService(meta);

// Construct the server
Expand Down Expand Up @@ -90,7 +90,7 @@ public void join() throws InterruptedException {
}

public static void main(String[] args) {
final HsqldbServer server = new HsqldbServer();
final StandaloneServer server = new StandaloneServer();
new JCommander(server, args);

server.start();
Expand Down Expand Up @@ -134,4 +134,4 @@ private enum ExitCodes {
}
}

// End HsqldbServer.java
// End StandaloneServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
*/

/**
* Avatica Server for HSQLDB.
* Avatica Server without any authentication for any JDBC driver.
*/
@PackageMarker
package org.apache.calcite.avatica.hsqldb;
package org.apache.calcite.avatica.server;

import org.apache.calcite.avatica.util.PackageMarker;

Expand Down

0 comments on commit 8bac70e

Please sign in to comment.