Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- |_child (column 2)
- |_sub-child (column 3)
- package JAVA;
- import java.util.List;
- public class json {
- private String parent;
- private List<String> child1;
- private List<String> child2;
- public String getparent() {
- return parent;
- }
- public void setparent(String parent) {
- this.parent =parent;
- }
- public List<String> getchild1() {
- return child1;
- }
- public void setchild1(List<String> child1) {
- this.child1 = child1;
- }
- public List<String> getchild2() {
- return child2;
- }
- public void setchild2(List<String> child2) {
- this.child2 = child2;
- }
- }
- package JAVA;
- <%@page import="java.util.List"%>
- <%@page import="java.util.ArrayList"%>
- <%@page import="com.google.gson.GsonBuilder"%>
- <%@ page import="java.sql.*" %>
- <%@page pageEncoding=
- "UTF-8" contentType="text/html; charset=UTF-8"%>
- <%@ page import="jj.j1"%>
- <%@ page import="com.google.gson.Gson" %>
- <H1>Fetching Data From a Database</H1>
- <%
- Class.forName("com.mysql.jdbc.Driver");
- Connection con=DriverManager. getConnection
- ("jdbc:mysql://localhost:3306/tree","root","admin321");
- Statement statement = con.createStatement();
- ResultSet resultset =
- statement.executeQuery("select * from tab") ;
- if(!resultset.next()) {
- out.println("Sorry, could not find . ");
- } else {
- %>
- <%
- }
- %>
- <% resultset.getString(1) ; %>
- <%
- j1 obj = new j1();
- List<String> child1 = new ArrayList<String>() ;
- while(resultset!=null){
- }
- {
- child1.add(resultset.getString(2));
- out.println(child1);
- }
- List<String> child2 = new ArrayList<String>() ;
- while(resultset!=null){
- }
- {
- child2.add(resultset.getString(3));
- out.println(child2);
- }
- }
- %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement