Giter Site home page Giter Site logo

peter-gergely-horvath / dyna4jdbc Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 1.0 1.98 MB

A JDBC driver for running alternative JVM language scripts or console-oriented programs

Home Page: http://dyna4jdbc.org/

License: Apache License 2.0

Java 99.71% Groovy 0.29%

dyna4jdbc's People

Contributors

lazabazsa avatar peter-gergely-horvath avatar pgh-tba avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

lazabazsa

dyna4jdbc's Issues

Add proper JDBC driver service provider configuration

From the JDBC DriverManager documentation:

The DriverManager methods getConnection and getDrivers have been enhanced to support the Java Standard Edition Service Provider mechanism. JDBC 4.0 Drivers must include the file META-INF/services/java.sql.Driver. This file contains the name of the JDBC drivers implementation of java.sql.Driver. For example, to load the my.sql.Driver class, the META-INF/services/java.sql.Driver file would contain the entry:

my.sql.Driver

Applications no longer need to explictly load JDBC drivers using Class.forName().

Fix invalid handling of empty result set metadata

java.sql.SQLException: JDBC Error [JDBC_API_USAGE_CALLER_ERROR]: Illegal JDBC API call: Result set is empty!
at com.github.dyna4jdbc.internal.JDBCError.raiseSQLException(JDBCError.java:66)
at com.github.dyna4jdbc.internal.common.jdbc.generic.EmptyResultSet.getMetaData(EmptyResultSet.java:199)

Some scope for potential cleanup in the pom?

Hi, quickly scanning the source code, it seemed like it was Java, so perhaps there is no compile dependency on renjin or scala? Perhaps they should be marked as optional, or if in tests as test scope?
Also, Renjin seemed to have version RELEASE in the pom which didn't seem to exist?

Anyway, nice library, I had fun playing in my little Groovy->SQL->Groovy trial:

@Grab('com.github.peter-gergely-horvath:dyna4jdbc:1.0.0')
@GrabExclude('org.scala-lang:scala-compiler')
@GrabExclude('org.renjin:renjin-script-engine')
@GrabExclude('org.scala-lang:scala-library')
@GrabConfig(systemClassLoader=true)
import groovy.sql.Sql

def script = '''
def fields = [t: 'Ticker', name: 'Name', l_cur: 'Close']
def base = 'http://www.google.com/finance/info?infotype=infoquoteall&q'
def url = new URL("$base=NASDAQ:AAPL,IBM,MSFT,GOOG")
def json = url.text.replaceFirst("//", "")
def data = new groovy.json.JsonSlurper().parseText(json)
println fields.values().collect{ "$it::" }.join('\t')
data.each { row -> println fields.keySet().collect{ row[it] }.join('\t') }
'''

def url = 'jdbc:dyna4jdbc:scriptengine:groovy'
Sql.withInstance(url) { sql ->
  sql.eachRow(script){ row -> println "$row.Ticker $row.Close" }
}

Would be nice to get rid of the @GrabExclude statements but a minor issue for now.

Improve process runner detection of process stream's end

Currently, process runner uses heuristics (timeout) to detect that an external process does not have any additional data to return: if a process does not generate any output for 5 seconds, it is considered to be finished with processing and result set is returned to the caller.

Improve this somehow: Configurable timeout? Configurable EOS tag in output? Investigate it further!

Process runner does not handle stream end gracefully

Process runner does not handle stream end gracefully (behaviour should be correct, but stream end should be a SQL warning and not a console log)

com.github.dyna4jdbc.internal.processrunner.jdbc.impl.ProcessManager$BufferedReaderToBlockingQueueRunnable.run(ProcessManager.java:187)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: Stream closed
	at java.io.BufferedInputStream.getBufIfOpen(BufferedInputStream.java:170)
	at java.io.BufferedInputStream.read1(BufferedInputStream.java:283)
	at java.io.BufferedInputStream.read(BufferedInputStream.java:345)
	at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284)
	at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326)
	at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
	at java.io.InputStreamReader.read(InputStreamReader.java:184)
	at java.io.BufferedReader.fill(BufferedReader.java:161)
	at java.io.BufferedReader.readLine(BufferedReader.java:324)
	at java.io.BufferedReader.readLine(BufferedReader.java:389)
	at com.github.dyna4jdbc.internal.processrunner.jdbc.impl.ProcessManager$BufferedReaderToBlockingQueueRunnable.run(ProcessManager.java:179)
	... 3 more
Exception in thread "pool-24-thread-2" java.lang.RuntimeException: java.io.IOException: Stream closed
	at com.github.dyna4jdbc.internal.processrunner.jdbc.impl.ProcessManager$BufferedReaderToBlockingQueueRunnable.run(ProcessManager.java:187)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: Stream closed
	at java.io.BufferedInputStream.getBufIfOpen(BufferedInputStream.java:170)
	at java.io.BufferedInputStream.read1(BufferedInputStream.java:283)
	at java.io.BufferedInputStream.read(BufferedInputStream.java:345)
	at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284)
	at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326)
	at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
	at java.io.InputStreamReader.read(InputStreamReader.java:184)
	at java.io.BufferedReader.fill(BufferedReader.java:161)
	at java.io.BufferedReader.readLine(BufferedReader.java:324)
	at java.io.BufferedReader.readLine(BufferedReader.java:389)
	at com.github.dyna4jdbc.internal.processrunner.jdbc.impl.ProcessManager$BufferedReaderToBlockingQueueRunnable.run(ProcessManager.java:179)```

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.