Created
March 21, 2021 12:31
-
-
Save pwntester/5cb7d2b3aac64b5229b49b991ede58d8 to your computer and use it in GitHub Desktop.
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
package org.pwntester.jaxrs_jdbc; | |
import com.fasterxml.jackson.annotation.JsonProperty; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.jdbc.core.JdbcTemplate; | |
import org.springframework.jdbc.core.RowCallbackHandler; | |
import javax.ws.rs.*; | |
import javax.ws.rs.core.MediaType; | |
import java.sql.ResultSet; | |
import java.sql.SQLException; | |
@Path("/hello-world") | |
public class HelloResource { | |
@Autowired | |
private JdbcTemplate template; | |
@POST | |
@Path("/xyz") | |
@Consumes(MediaType.APPLICATION_JSON) | |
@Produces(MediaType.APPLICATION_JSON) | |
public String doQuery(SearchQuery sql) { | |
template.query(sql.queryName, new RowCallbackHandler() { | |
@Override | |
public void processRow(ResultSet resultSet) throws SQLException { | |
System.out.println("foo"); | |
} | |
}); | |
return "Hello, World!"; | |
} | |
public static class SearchQuery { | |
@JsonProperty("queryName") | |
public String queryName; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment