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



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Mohamad
mysql
1 Answer(s)      5 years and 8 months ago
Posted in : WebSevices



Advertisement
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.io.*;
import java.sql.*;

public class FetchDatabase{
public static void main(String[] args) {
Connection con = null;
try{
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root";);
try{
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;
while(rst1.next()){
limit1=rst1.getInt(1);
}
rst1.close();
rst2 = st.executeQuery("select count(*) from users");
while(rst2.next()){
limit2=rst2.getInt(1);
}
rst2.close();
int count =1;
while(count < (limit1+limit2)){
rst3 =st.executeQuery("select * from country limit "+count+",1");
if(count < limit1){
boolean bool = rst3.next();
System.out.print(rst3.getInt(1)+" ");
System.out.println(rst3.getString(2));

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

Thanks
RoseIndia Team

Thanks


Related Tutorials/Questions & Answers:
MYSQL
MYSQL  How to create time and date based trigger in mysql   MySQL Time Trigger
mysql
mysql  how to open\import table in .dbf format in mysql
Advertisements
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
mysql
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
mysql  want the code for mysql nested select query with single where condition.want to select data from more than one table
MySQL
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
MySQL NOT IN
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 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
Dateformat in MySQL
Dateformat in MySQL  Date format in MySQL
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 connect
Mysql connect  i can have a mysql database file and mysql-connector-net .but i have not mysql database. how to connect vb.net thsis database.(C:\Documents and Settings\Admin\My Documents\VB.NET\Stock delna\STC.sql ). plz help me
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: http://www.roseindia.net/sql/mysql-table/mysql-php-select.shtml 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: http://www.roseindia.net/struts/struts2/struts-2-mysql.shtml
Image in mysql
Image in mysql  Hi. How to insert and retrieve images in mysql db using JSP or JAVA Servlet? Thanks in advance
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
JSP &MYSQL
JSP &MYSQL  Develop a web page for the telephone directory using jsp and mysql
java-mysql
java-mysql  how i retrive all the values of a table in mysql to java forms or java table
mysql - SQL
mysql  How to insert the check box values in mysql database through php
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
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
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
MySQL - SQL
MySQL  how to set a time to repeat a trigger in Mysql?  Hi Friend, Please visit the following links: http://www.roseindia.net/mysql/mysql5/triggers.shtml http://www.roseindia.net/sql/trigger/mysql-time
user in mysql
user in mysql  how to create user in mysql?   Please visit the following link: http://www.roseindia.net/mysql/mysql5/mysql-creating-account.shtml
connectivity with mysql
/phpdatabase/Check-PHP-MySQL-Connectivity.html   Please visit the following.../tutorial/php/phpdatabase/ http://www.roseindia.net/sql/mysql-example/php-mysql
mysql - SQL
mysql  hi i am using mysql. i want to create simple table...=INNODB; For more information MySql visit to : http://www.roseindia.net/mysql/ Thanks
mysql - WebSevices
mysql  Hello, mysql storing values in column with zero,but there is no 0.after 0 it is storing my values which i have extract from the file... when I want to store this value in mysql it store 0 first and than 60
mysql - MobileApplications
* FROM Persons WHERE unit='india' For read more information on JDBC-Mysql visit to : http://www.roseindia.net/jdbc/jdbc-mysql/ http
MYSQL - SQL
MYSQL  how to select last row in table?(MYSQL databse)   How to select last row of the table in mySql Here is the query given below selects tha last row of the table in mySql database. SELECT * FROM stu_info
Mysql Not
Mysql Not       Mysql... with Example The Tutorial illustrate an example from 'MySQL Not'. The Select... for Mysql not : select !0 : The !0 in the select Query is used to return 1.   
Advertisements
 

 

 

DMCA.com