Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


vrushali suryawanshi
json
1 Answer(s)      3 years and 8 months ago
Posted in : JavaScript Questions


how to get data in json object from database


Advertisement
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
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
JEE7 JSON: How to use JEE 7 JSON API?
JEE7 JSON: How to use JEE 7 JSON API? In this tutorial I will explain you how you can use JEE 7 JSON API in your program for consuming and generating the JSON data on fly. The JSON stands for JavaScript Object Notation. The JSON
Advertisements
 

 

 

DMCA.com