1

so here is my question i want to get all my database values from MYSQL using javascript.. as i am researching it in google it is possible but i don't know if it needs a configuration because i am using a spring hibernate in maven here is the link that i found How to get data from database in javascript based on the value passed to the function

i am trying to get the values from my database because i am doing a highchart for my website.. thank you very much in advance..

if there are any possible ways to do it please comment also thank you again

Community
  • 1
  • 1

1 Answers1

1

You are already using Spring and Hibernate, so you need to implement a REST GET service to fetch the data you need and then simply feed it to your java script component.

So it goes like this:

  1. The browser makes an AJAX request to the REST service
  2. The REST service calls the Spring service which calls the DAO component
  3. The DAO component fetches the required data (entities/DTO projections)
  4. Configure the Spring MVC REST controller to Use Jackson for serializing the entities/DTO projections to JSON
  5. The ajax call response handler can simply use the JSON provided by the server to feed highcharts
Vlad Mihalcea
  • 142,745
  • 71
  • 566
  • 911
  • actually sir i am a newbie in spring hibernate and i am not familiar on the REST but regarding to DAO i already have one and it is ready to be convert into JSON but i don't know how and i don't know how to use it in javascript.. i am only familiar using a .json file so that i can work my highchart. i thank you very much for replying i've been waiting for someone to answer my question.. i can post my code if you want –  Jan 03 '15 at 09:02
  • The question is answered. For parsing JSON using your JS library you need to ask a new question. – Vlad Mihalcea Jan 03 '15 at 09:48
  • ok now i got already the JSON that i want so i type in the url localhost:8081/Project/project/xyz but how do i pass this JSON so i can use it in my javascript? im sorry if i have a lot of question –  Jan 03 '15 at 09:59
  • 1
    You don't need to do anything special. Json is a valid JS object. Just get it from the response and use it. – Vlad Mihalcea Jan 03 '15 at 10:14
  • thank you very much! you give me an idea and i already get my json to my javascript –  Jan 03 '15 at 10:56