Created
December 24, 2013 05:30
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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