Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 1 of 1

Thread: Rest API - get empty brackets instead of json when sending GET request

  1. #1
    Junior Member
    Join Date
    Nov 2019
    Thanked 0 Times in 0 Posts

    Default Rest API - get empty brackets instead of json when sending GET request

    Hello. I really need help. I've been trying to solve this for days now. I am quite a newbie and am going crazy.

    I have a maven project. I can succesfully bring out data from my database into the console in my application server. However, when I try to use a restful services and use Postman to get the data out it only returns an empty pair of brackets [] instead of the data in json-format! I've tried various ways to solve it but this I won't get pass this... I have tried to convert it to Json using GSON before I request it but it doesn't work.

    RESTful webservice:
        public Response getJson() {
                List<ResultLadok> results = DriverDBLadok_testing.getLadokResultsArrayList();
            return Response.ok(results)
    package controller_ladok;
    public class DriverDBLadok_testing {
        public static List<ResultLadok> resultList = new ArrayList();
        static String jsonString;
        public DriverDBLadok_testing() {
        public List<ResultLadok> getResultList() {
            return resultList;
        public void setResultList(List<ResultLadok> resultList) {
            this.resultList = resultList;
        //method to put result in List
        public static void addResult(String betyg, int poang, int provNr, String termin, 
                String datum, String kurskod, String kurstillfalle){
            ResultLadok resLadok = new ResultLadok();
        //method to get DB data to arrayList
        public static List<ResultLadok> getLadokResultsArrayList(){
                //1. get a connection to database
                Connection myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/ladoksimulation", "root", "admin");
                //2. create a statement
                Statement myStmt = myConn.createStatement();
                //3. Execute SQL query
                ResultSet myRs = myStmt.executeQuery("select * from resultat");
                //4. process the result set
                    addResult(myRs.getString("betyg"), myRs.getInt("poäng"), myRs.getInt("provNr"),
                             myRs.getString("termin"), myRs.getString("date"), myRs.getString("kurskod"),
            catch(Exception exc){
            return resultList;
    Pom file: 
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    Thanks in advance...
    Last edited by Helgesson; November 11th, 2019 at 02:45 PM. Reason: Problems attaching the code

Similar Threads

  1. consume the rest service by passing the json object
    By StarRocks in forum Object Oriented Programming
    Replies: 0
    Last Post: January 29th, 2013, 06:28 AM
  2. [Request]Explanation about sending and recieving data
    By 123099 in forum Java Networking
    Replies: 6
    Last Post: October 6th, 2011, 12:41 PM
  3. Sending large Strings ?! only sending a line
    By camel in forum Java Networking
    Replies: 2
    Last Post: April 19th, 2011, 12:41 PM
  4. Problem sending POST request with Java..
    By lost in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 20th, 2010, 09:16 PM