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



Home Answers Viewqa Ajax table structure
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


V.A.G.Raju
table structure
1 Answer(s)      6 years and 4 months ago
Posted in : Ajax



Advertisement
View Answers

September 17, 2008 at 7:44 PM


Use this code, no need to change, As per your database scenario, I design.

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class Data extends HttpServlet {
private int countryID;
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException{

String value = req.getParameter("country");
String dbQuery1 = "Select country_ID FROM TB_countries WHERE country_name='" + value + "'";
String dbQuery2 = "";

PrintWriter out = res.getWriter();
String result="";
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/ashok";, "root", "mysql");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(dbQuery1);
while(rs.next()){
countryID = rs.getShort("country_ID");
}
dbQuery2 = "Select state_name FROM TB_states WHERE country_ID=" + countryID;
rs = stmt.executeQuery(dbQuery2);
while(rs.next()){
result = result + rs.getString("state_name") + ",";
}
}catch(Exception ex){

System.out.println(ex.getMessage());

}
out.write(result);
}

}

Thanks
Rajanikant


Related Tutorials/Questions & Answers:
table structure - Ajax
table structure  This is my table structures.Please modify the code. TB_countries +--------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra
structure in JSP
structure in JSP  How do I achieve structure in JAVA or JSp
Advertisements
structure example
structure example  in the example above what do you call the names student1,student2 and student3   Post the code
Array of structure
Array of structure  create employment details with necessary field using array of structure
Data structure
Data structure: How to sort numbers in a queue using a bubble sort method?  How to sort numbers in a queue using a bubble sort method
C Structure
C Structure  Respected sir, Can a structure in C contain a pointer to itself ? if yes means how sir ? plz help me sir
inbox structure
inbox structure  I want to create an inbox for my project in which records are to be fetched dynamically. I am using netbeans (jsp + javascript+ servlet.) The structure is same like yahoo inbox (1st column full of check boxes
Mysql Alter Table Identity
Mysql Alter Table Identity       Mysql Alter Table Identity is used to change the existing structure of table and add ID column as identity key that is used to uniquely define
mysqldump structure only
mysqldump structure only  Hi, How to take dump of database structure only? Provide me the syntax to take mysqldump structure only. Thanks   Hi, You can use -d option with mysqldump command to take the structure only
Drop Table
Drop Table       Drop Table in SQL get rid of an object or table from the database. Using a drop Query get rid of all the rows deleted from the table and the structure
tables to structure forms
tables to structure forms  How can I use tables to structure forms
use tables to structure forms
use tables to structure forms  How can I use tables to structure forms
tables to structure forms
tables to structure forms  How can I use tables to structure forms
use tables to structure forms
use tables to structure forms  How can I use tables to structure forms
table
table  multiplicatyion table
MySQL Directory Structure
MySQL Directory Structure      ... scale sequence search the approaches as well as mysql table. These table dumps... the installation. The MySQL support Ensemble downloading of many correlation table
TABLE
TABLE   Why doesn't <TABLE WIDTH="100%"> use the full browser width
MLM tree structure
MLM tree structure  i want mlm tree structure code in php .Please help me..... thanks in advance
Mlm tree structure
Mlm tree structure  i want mlm tree structure code in php with jquery or Ajax
Mlm tree structure
Mlm tree structure  i want mlm tree structure code in php with jquery or Ajax
Mlm tree structure
Mlm tree structure  i want mlm tree structure code in php with jquery or Ajax
Table
Table  How i generate table in showMessageDialog. I want that i creat a table and run in showMessageDialogeprint("cprint("code sample");ode sample
What is the structure of Spring framework?
What is the structure of Spring framework?  What is the structure of Spring framework?   Hi, In Java Spring framework offers one-stome... Framework structure this link. Thanks
Directory structure of a web application
Directory structure of a web application   Explain the directory structure of a web application.    The directory structure of a web application consists of two parts. A private directory called WEB-INF. A public
Table
Table  How i generate table in showMessageDialog. I want to creat a table and run in showMessageDialoge. Pl make a table programe which run..., JOptionpane, Integer.parseInt. Please use only these above methods to make table
Table
Table  How I generate table in showMessageDialog. E.g 3X1=3 3X2=6 3X3=9print("code sample
Table
Table  How i generate table in JOptionpane.showMessageDialog... advance coding but i want u make the table using JOptionpane.showMessageDialog, import.javax.swing int Integer.parseInt(). Thats my limit. Pl generata a table
table
table  Hi..I have a list of links which links to a table in the same page.If I click first link the table is displayed at the top, likewise if i click the last link the table is displayed at the last,i dont know how to set
table
input from oracle table(my database table..) This is a very important table of my
cylinder tree structure
materials in a hierarchical structure in a cylinder form. for example my interface... code to create the tree structure. your advice will be very very appreciated
table?
table?  Hi, how could i make a table in javascript, which would look like this: AA CODON Number /1000 Fraction .. (this row... can't figure out, how to construct a table,with two fixed columns, one that reads
 

 

 

DMCA.com