Skip to content

Instantly share code, notes, and snippets.

@jpokrzyk
Created December 24, 2013 05:30
Show Gist options
  • Save jpokrzyk/8109151 to your computer and use it in GitHub Desktop.
Save jpokrzyk/8109151 to your computer and use it in GitHub Desktop.
Vertx JDBC groovy example which causes java.sql.SQLException: No suitable driver found for jdbc:jtds:sqlserver://AnyServer:1433/AnyDB Run with: vertx run app.groovy -cp lib/jtds-1.3.1.jar
import org.vertx.groovy.core.http.RouteMatcher
import groovy.sql.Sql
def rm = new RouteMatcher()
rm.getWithRegEx('.*') { req ->
def db = [url:'jdbc:jtds:sqlserver://AnyServer:1433/AnyDB', user:'test', password:'test', driver:'net.sourceforge.jtds.jdbc.Driver']
Sql sql = Sql.newInstance(db.url, db.user, db.password, db.driver)
def result = sql.firstRow("select * from AnyTable")
sql.close()
req.response.end result.HCI_Filename
}
vertx.createHttpServer().requestHandler(rm.asClosure()).listen(8080)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment