Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training  




Share on Google+Share on Google+

1 Answer(s)      8 years ago
Posted in : WebSevices
View Answers

May 4, 2009 at 3:44 PM

Hi Friend,

We are providing you the sample code which will help you in solving your problem. You can make use of it to find your solution.

import java.sql.*;

public class FetchDatabase{
public static void main(String[] args) {
Connection con = null;
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root";);
Statement st = con.createStatement();
ResultSet rst1 =null;
ResultSet rst2 =null;
ResultSet rst3 =null;
ResultSet rst4 =null;
rst1 = st.executeQuery("select count(*) from country");
int limit1=0;
int limit2=0;
rst2 = st.executeQuery("select count(*) from users");
int count =1;
while(count < (limit1+limit2)){
rst3 =st.executeQuery("select * from country limit "+count+",1");
if(count < limit1){
boolean bool =;
System.out.print(rst3.getInt(1)+" ");

rst4 =st.executeQuery("select * from users limit "+count+",1");
if(count < limit2){
boolean bool =;
System.out.print(rst4.getInt(1)+" ");
System.out.print(rst4.getString(2)+" ");
System.out.print(rst4.getString(3)+" ");
catch (SQLException s){
System.out.println("SQL statement is not executed!");
catch (Exception e){

RoseIndia Team



Related Tutorials/Questions & Answers:
MYSQL  How to create time and date based trigger in mysql   MySQL Time Trigger
mysql  how to open\import table in .dbf format in mysql
MySql  what is default password of mySql, and how i configure mySql.   Hi, If you are installing MySQL on windows then you will have to provide the Password for the user root at the installation time. You may try
you need to download the mysql-connector jar file for connecting java program from mysql database.......   Hi friend, MySQL is open source database... is the link for the page from where you can understand how to Download and Install MySQL
mysql  want the code for mysql nested select query with single where condition.want to select data from more than one table
MySQL In this section we will read about what is MySQL, MySQL distribution, MySQL features, MySQL architecture etc. MySQL unofficially, pronounced as My... the database. The development, distribution, and support of MySQL is done
Dateformat in MySQL
Dateformat in MySQL  Date format in MySQL
mysql doubt
mysql doubt  1.What are the method to write malayalam in mysql command prompt?Is it necessary to write malayalam corressponding unicode in mysql command prompt? 2.How to store & retrieve Malayalam from mysql databases
Mysql connector
Mysql connector  Wer can i get mysql-connector? Is it jar or exe file.../pub/mirrors/maven/mysql/jars/mysql-connector-java-5.0.5.jar It will provide you the download option for mysql-connector-java-5.0.5.jar file. Thanks
MySQL NOT IN In this section we will read about how to use the NOT IN function in MySQL with a simple example. MySQL NOT IN() function specifies... will demonstrate you about how to use MySQL not in() function. In this example we
Mysql connect
Mysql connect  i can have a mysql database file and mysql-connector-net .but i have not mysql database. how to connect thsis database.(C:\Documents and Settings\Admin\My Documents\VB.NET\Stock delna\STC.sql ). plz help me
Fortran with mysql
Fortran with mysql  Can i connect mysql with Fortran using java
MYSQL Database
MYSQL Database  Can any one brief me about how to use MYSQL Database..., the MySQL database server is most popular database server and if you want to know about creating table and using MYSQL, just follow the below link
mysql - SQL
mysql  hi i want to export my data from mysql to excel using php script. pls help me  Hi Friend, Please visit the following link: Thanks
MYSql with struts
MYSql with struts  How to write insert and update query in struts by using mysql database?   Please visit the following link:
mysql - SQL
mysql  How to insert the check box values in mysql database through php
java-mysql  how i retrive all the values of a table in mysql to java forms or java table
JSP &MYSQL  Develop a web page for the telephone directory using jsp and mysql
php mysql
php mysql  automatically insert a value in the month field at the last date of current month in mysql database
php mysql
php mysql  automatically insert a value in the month field at the last date of current month in mysql database
Image in mysql
Image in mysql  Hi. How to insert and retrieve images in mysql db using JSP or JAVA Servlet? Thanks in advance
Java and Mysql
Java and Mysql  Sir, I want to connect my java program with mysql server (mysql server is situated on another windows machine ) ??? ???? ?????   Put mysql jar file in your jdk lib and set the classpath. After
MySQL  how to set a time to repeat a trigger in Mysql?  Hi Friend, Please visit the following links:
Java and MySQL
Java and MySQL   I am doing a project on an accounting system. I need to know to things: How do I write reports using information in an MySQL database . How get multiple MySQL database rows and assign them to variables r
user in mysql
user in mysql  how to create user in mysql?   Please visit the following link:
connectivity with mysql
/phpdatabase/Check-PHP-MySQL-Connectivity.html   Please visit the following.../tutorial/php/phpdatabase/
Mysql As
Mysql As       Mysql As is used to specify the another name for the existing column and table name... from 'Mysql As'. To understand this example we create a table 'stu'. The create
service mysql restart: cPanel MYSQL 5.1 to 5.5
service mysql restart: cPanel MYSQL 5.1 to 5.5  service mysql restart: cPanel MYSQL 5.1 to 5.5
Upgrading databases between MySQL 5.0 to MySQL 5.5
Upgrading databases between MySQL 5.0 to MySQL 5.5  Upgrading databases between MySQL 5.0 to MySQL 5.5
Mysql Upgrade on WHM (Mysql 5.1 to 5.5) - cPanel
Mysql Upgrade on WHM (Mysql 5.1 to 5.5) - cPanel   Mysql Upgrade on WHM (Mysql 5.1 to 5.5) - cPanel
Mysql Upgrade on WHM (Mysql 5.1 to 5.5)cPanel
Mysql Upgrade on WHM (Mysql 5.1 to 5.5)cPanel   Mysql Upgrade on WHM (Mysql 5.1 to 5.5) cPanel