Share on Google+Share on Google+

vrushali suryawanshi
json
1 Answer(s)      6 years and a month ago
Posted in : JavaScript Questions

how to get data in json object from database

Ads

View Answers

March 4, 2011 at 12:59 PM


How to get data in json object from database

<%@ page language="java" import="net.sf.json.JSONArray,java.sql.*,java.util.*" %>

 <%
 Class.forName("com.mysql.jdbc.Driver");
  Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
  Statement st=con.createStatement();
  ResultSet rs=st.executeQuery("select * from employee where id=1");
  JSONArray arrayObj=new JSONArray();
  while(rs.next()){
   arrayObj.add(rs.getString("name"));
   arrayObj.add(rs.getString("address"));
   arrayObj.add(rs.getInt("contactNo"));
   arrayObj.add(rs.getString("email"));
  }
%>
<h2>Array Object is =></h2>
<br>
<%  for(int i=0;i<arrayObj.size();i++){  %>
          <%=arrayObj.getString(i)%><br>
<%
  }
%>









Related Tutorials/Questions & Answers:
json
json  how connect ajax with json
json
json  how to get data in json object from database
Advertisements
json
data is transferred and how it is encoded. While JSON is a tool used for describing values and objects by encode the content in a very specific manner. 2)JSON... in JavaScript.While AJAX uses JSON format to communicate between client
json
json   how to develop iphone web service application using json. Please help me by giving any link where I could find an example or any help will be anticipated
JSON
it using JSON   The given code parse the message in JSON in JavaScript. You can parse the message with JSON in JavaScript by using the method "String.parseJSON(filter)". It parses the JSON message to an string or object
JSon Tutorial
JSon Tutorial  What is JSon? Where i can find the JSon tutorial? Thanks!   JSon Tutorial
JSON with Java
JSON with Java  How to request Json From URI and to parse and to store the values in Java array
Siverlight JSON
Siverlight JSON  how to use JSON in silverlight, i need to populate dynamic data by using JSON CAN ANY HELP ME   Hi Friend, Please go through the following link: http://www.roseindia.net/tutorials/json/ Thanks
json and android
json and android  how can i use a json string [{"Id":10,"News":"sportnews"}] and fill a spinner for a android app?. i tried and i got a: AndroidRuntime:android.widget.ArrayAdapter.createViewFromResource(Adapter
Ajax json
Ajax json  Hi, How consume json file in ajax program? Thanks
JSON to HashMap
JSON to HashMap  Hi, How to convert a JSON String to HashMap in Java... following code for conversion of JSON String to HashMap: String jsonString = "Your JSON string"; HashMap<String,String> map = new Gson().fromJson
JEE 7 JSON java.lang.NoClassDefFoundError: javax/json/Json
JEE 7 JSON java.lang.NoClassDefFoundError: javax/json/Json  Hi, While using the JSON in jee 7 based application I getting following errors...(Thread.java:724) Caused by: java.lang.NoClassDefFoundError: javax/json/Json
A better Java JSON library?
A better Java JSON library?   A better Java JSON library
what is json in iphone sdk
what is json in iphone sdk  What is json in iphone sdk? Is this a library and when i need to include JSon in my iPhone SDK App
What is JSON?
What is JSON? In this article we are discussing about the JSON which... application. JSON- JavaScript Object Notation JavaScript Object Notation is a data... transfer from one place to another easy. Though JSON is based on Java Script
JSON main question
JSON main question  What is the main purpose of JSON ,in which cases can i use
JSON main question
JSON main question  What is the main purpose of JSON ,in which cases can i use
JSON-RPC
JSON-RPC       JSON-RPC-Java is a dynamic JSON-RPC implementation in Java. It allows you to transparently call server-side Java code from JavaScript with an included lightweight JSON-RPC
jQuery ajax json
jQuery ajax json  Hi, How to use jQuery to load json data through... to crate the json response: JSONObject obj=new JSONObject(); obj.put("name","foo..., textStatus, xhr) ] ) at client side to process the json data. Thanks
JSON Tutorials
JSON Tutorials       In this tutorial I will teach you about the JSON language which is used mostly on Internet for transferring the data over the network. JSON
How to sort json object?
How to sort json object?  I've been looking for a while and want a way to sort a JSON object like this: {"results": [ { "layerId": 5, "layerName": "Pharmaceutical Entities", "attributes": { "OBJECTID": "35
Difference between jsonstring and json object
Difference between jsonstring and json object  Is There any difference between JsonString and jsonobjectA? if there is any differece could any one explain with example. Thanks venkatesh
JSON-JSP example
JSON-JSP example       In the previous section of JSON-Servlet example you have learned how to create a servlet class by using JSON classes. Now in this example we
retrieve JSON array objects in javascript
retrieve JSON array objects in javascript  I am getting one value by JSON array, but how can i store multiple values in json array and how can i...); response.setContentType("application/json"); response.getWriter().write
JSON array objects retrieval in javascript
JSON array objects retrieval in javascript   I am fetching some data... box is not populating any value, perhaps i am doing something wrong in json...("application/json"); response.getWriter().write(jsonObj.toString()); want to get above
JSON in JavaScript
JSON in JavaScript       JSON stands for JavaScript Object Notation that ... conventions.  So in this section of JSON tutorial we are going to discuss
JSON and Servlet example
JSON and Servlet example       In the previous section of JSON-Java example you have learned how to create a java class by using JSON classes. Now in this example
Getting Json data from servlet to javascript variable
Getting Json data from servlet to javascript variable  How do i get json data from my servlet on to a variable in javascript n bind the data to display onto sigma grid.Has anyone Idea how to do
how to create this structure in json using grails
how to create this structure in json using grails  { "query": { "type": "cluster", "view": "accountActivity", "regions": [2342,334,241,13], "companies": [43228583,433421683,342427783], "departments": [1,2,4,6], "brands
Parsing a message in JavaScript with JSON
Parsing a message in JavaScript with JSON... we have studied how to create message in JSON in JavaScript and now we will come to know that how we can parse the message in JSON in JavaScript. We can
JSON-RPC-Java
JSON-RPC-Java       JSON-RPC-Java is an AJAX RPC middleware that allows JavaScript DHTML web applications to call remote methods in a J2EE Application Server and Transparently maps Java
Tutorials   
Java Spring Hibernate Struts Training code for programming How can I dynamically load user-entered data as content of jquery dialog? java webcam integration question java coding Fix Scrollbar position in a checkboxList after postback Information Save Alert Country wise redirection to files Interface in javascript connect database with javascript Zip Code ZipCode how to validate the email login How to play FLV video files on Ipad using HTML code or javascript code? Nitobi Grid is not working in IE10/IE11 jquery issue plese help RegEx Tree structure from json whose parents can be dragged and dropped from child newyorklife insurance getElementById not working javascript code for search in html file Implement The Skeleton Code Implement This Skeleton Code Mobile Automation using Appium Computer forensic application Java: Searching a string from doc files java linked list urgent !!! java linked list urgent!!! library management library management library management library management question Html form using JavaScript to display the table content java how to prevent no from unroundin off on clicking text box again in JSP and Jquery graph generation from xml design file display data from database in textbox when id entered in textbox Javascript Code for all fields how to get HTTP GET request value using javascript array Javascript Querry autocomplete(): Spring mvc with jquery: I am not getting correct value in the text filed. Please help me Create SpreadSheet same as excel using java applet Create SpreadSheet same as excel using java applet How to change focus among multiple select boxes? Write JQUERY Code Write JQUERY Code Converting jsp variable to java variable java

Ads

 
Advertisement null

Ads