table structure

table structure

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
table
table  multiplicatyion table
Advertisements
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
TABLE
TABLE   Why doesn't <TABLE WIDTH="100%"> use the full browser width
Table
Table  How i generate table in showMessageDialog. I want that i creat a table and run in showMessageDialogeprint("cprint("code sample");ode sample
structure in JSP
structure in JSP  How do I achieve structure in JAVA or JSp
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
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 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
input from oracle table(my database table..) This is a very important table of my
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
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, 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
Table
Table  Why u dont understand sir?? I want to make a table program which generate a table on showMessageDialog. I have learnt these methods until now... methods to be used. Write a table program which use only and only these above methods
Table
Table  How i create table on showMessageDialog using JOptionpane and Integer.parseInt. No other method to use. Pl make a program which generate 5X1=5 5X2=10 5X3=15   Hi Friend, Try this: import javax.swing.*; import
Array of structure
Array of structure  create employment details with necessary field using array of structure
structure example
structure example  in the example above what do you call the names student1,student2 and student3   Post the code
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
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
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
Hibernate envers revinfo table
Hibernate envers revinfo table  Hi, What is the structure of hibernate envers revinfo table? What is the use of envers revinfo table and its structure? Thanks
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
use tables to structure forms
use 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
tables to structure forms
tables to structure forms  How can I use tables to structure forms
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
ModuleNotFoundError: No module named 'structure'
ModuleNotFoundError: No module named 'structure'  Hi, My Python... 'structure' How to remove the ModuleNotFoundError: No module named 'structure' error? Thanks   Hi, In your python environment you
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
MLM tree structure
MLM tree structure  i want mlm tree structure code in php .Please help me..... thanks in advance
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.ADS
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
Structure of Web Module
In this section, you will learn the structure of the web module
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
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 is removed
ModuleNotFoundError: No module named 'demo-structure'
ModuleNotFoundError: No module named 'demo-structure'  Hi, My... named 'demo-structure' How to remove the ModuleNotFoundError: No module named 'demo-structure' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'demo-structure'
ModuleNotFoundError: No module named 'demo-structure'  Hi, My... named 'demo-structure' How to remove the ModuleNotFoundError: No module named 'demo-structure' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'foliantcontrib.alt-structure'
ModuleNotFoundError: No module named 'foliantcontrib.alt-structure'  ...: No module named 'foliantcontrib.alt-structure' How to remove the ModuleNotFoundError: No module named 'foliantcontrib.alt-structure' error
ModuleNotFoundError: No module named 'lc-structure'
ModuleNotFoundError: No module named 'lc-structure'  Hi, My Python... 'lc-structure' How to remove the ModuleNotFoundError: No module named 'lc-structure' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'lc-structure'
ModuleNotFoundError: No module named 'lc-structure'  Hi, My Python... 'lc-structure' How to remove the ModuleNotFoundError: No module named 'lc-structure' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'lizard-structure'
ModuleNotFoundError: No module named 'lizard-structure'  Hi, My... named 'lizard-structure' How to remove the ModuleNotFoundError: No module named 'lizard-structure' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'python_structure'
ModuleNotFoundError: No module named 'python_structure'  Hi, My... named 'python_structure' How to remove the ModuleNotFoundError: No module named 'python_structure' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'python_structure'
ModuleNotFoundError: No module named 'python_structure'  Hi, My... named 'python_structure' How to remove the ModuleNotFoundError: No module named 'python_structure' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'python_structure'
ModuleNotFoundError: No module named 'python_structure'  Hi, My... named 'python_structure' How to remove the ModuleNotFoundError: No module named 'python_structure' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'structure-spider'
ModuleNotFoundError: No module named 'structure-spider'  Hi, My... named 'structure-spider' How to remove the ModuleNotFoundError: No module named 'structure-spider' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'structure-tensor'
ModuleNotFoundError: No module named 'structure-tensor'  Hi, My... named 'structure-tensor' How to remove the ModuleNotFoundError: No module named 'structure-tensor' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'structure-threader'
ModuleNotFoundError: No module named 'structure-threader'  Hi, My... named 'structure-threader' How to remove the ModuleNotFoundError: No module named 'structure-threader' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'demo-structure'
ModuleNotFoundError: No module named 'demo-structure'  Hi, My... named 'demo-structure' How to remove the ModuleNotFoundError: No module named 'demo-structure' error? Thanks   Hi, In your python

Ads