Last active
August 29, 2015 14:00
-
-
Save rodrigoSaladoAnaya/11063062 to your computer and use it in GitHub Desktop.
This file contains 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 | |
// Use this driver and put the jar in the classpath: | |
// http://mvnrepository.com/artifact/postgresql/postgresql/8.4-702.jdbc4 | |
def server = vertx.createHttpServer() | |
def routeMatcher = new RouteMatcher() | |
routeMatcher.getWithRegEx(".*") {req -> | |
def db = [ | |
url:'jdbc:postgresql://localhost/databasname', | |
user:'bdusr', | |
password:'bdpwd', | |
driver:'org.postgresql.Driver' | |
] | |
Sql sql = Sql.newInstance(db.url, db.user, db.password, db.driver) | |
def result = sql.rows("select * from portal_usuario") | |
sql.close() | |
req.response.end result.toString() | |
} | |
server.requestHandler( | |
routeMatcher.asClosure() | |
).listen( | |
8080, | |
'localhost' | |
) | |
//Show classpath elements | |
System.getProperty('java.class.path').split(':').each { | |
println "> ${it}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment