Java and MySQL

Java and MySQL

I am doing a project on an accounting system. I need to know to things:

  1. How do I write reports using information in an MySQL database .

  2. How get multiple MySQL database rows and assign them to variables r an array in java. Please help!!!

View Answers

May 20, 2013 at 1:05 PM

hi friend,

MySQL contains no form or reporting tools. To write and represent a report using MySQL and Java, you must have to extract the data from the database and then you have to write java code for representing the report. You can read data from the database and can write it into the excel file.

You may go through the link to know how to read data from database and write it into the excel file.

http://www.roseindia.net/tutorial/java/poi/insertIntoExcelFileData.html

To assign database rows values in an array variables, you write your code like below

String sql = "SELECT * FROM register ";
    ps = con.prepareStatement(sql);
    ResultSet rs = ps.executeQuery();   
    rs.last();
    int numberOfRows = rs.getRow(); 
    int arr [] = new int [numberOfRows]; 
    rs.beforeFirst();
    for (int i = 0; i < arr.length; i++)
    {
    while(numberOfRows > 0 && rs.next())
    {
        arr[i] = rs.getInt("id");
        out.println("id = "+arr[i]);        
    }
    }

Thanks.









Related Tutorials/Questions & Answers:
java-mysql
java-mysql  how i retrive all the values of a table in mysql to java forms or java table
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
Advertisements
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
Version of mysql>mysql-connector-java dependency
List of Version of mysql>mysql-connector-java dependency
connection with MySQL to java.
connection with MySQL to java.   how to connect MySQL database with jsp
mysql-java
mysql-java   i try to execute this code stmt1.executeUpdate("insert... the manual that corresponds to your MySQL server version for the right syntax to use...) at Mydb.main(Mydb.java:111) Java Result: 1 please help me to find the error  
java & mysql
java & mysql  I wrote the code as shown below, i am getting the error... to your MySQL server version for the right syntax to use near '' at line 1" my...("com.mysql.jdbc.Driver"); Connection con=DriverManager.getConnection("jdbc:mysql
java & mysql
java & mysql  I wrote the code as shown below, i am getting the error... to your MySQL server version for the right syntax to use near '' at line 1" my...("com.mysql.jdbc.Driver"); Connection con=DriverManager.getConnection("jdbc:mysql
java & mysql
java & mysql  I wrote the code as shown below, i am getting the error... to your MySQL server version for the right syntax to use near '' at line 1" my...("com.mysql.jdbc.Driver"); Connection con=DriverManager.getConnection("jdbc:mysql
java & mysql
java & mysql  I wrote the code as shown below, i am getting the error... to your MySQL server version for the right syntax to use near '' at line 1" my...("com.mysql.jdbc.Driver"); Connection con=DriverManager.getConnection("jdbc:mysql
java & mysql
java & mysql  I wrote the code as shown below, i am getting the error... to your MySQL server version for the right syntax to use near '' at line 1" my...("com.mysql.jdbc.Driver"); Connection con=DriverManager.getConnection("jdbc:mysql
Java connectivity with MySQL
Java connectivity with MySQL  Java connectivity with MySQL
java with mysql
java with mysql  Hi, Here is my code: import java.awt.*; import...=DriverManager.getConnection("jdbc:mysql://localhost:3306/student","root","root...` VARCHAR(20) NOT NULL)"; con=DriverManager.getConnection("jdbc:mysql
MySql,java
MySql,java  In MySQL table i am adding the fields of name,photo,video,age,category.in the category i have some subjects.if one person login into my-site the he upload the one video under one subject.then i want the following
JAVA & MYSQL - JDBC
JAVA & MYSQL  How can we take backup of MySQL 5.0 database by using...;Hi Friend, Please visit the following page for working example of MySQL backup. This may help you in solving your problem. www.roseindia.net/mysql/mysql
Mysql & java - JDBC
Mysql & java  Hi guys, please help! I'm new to mysql, I want to connect to mysql 5.1 using java. But it shows error about: Class.forName...) { System.out.println("MySQL Connect Example."); Connection conn = null
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 Java Connector Library
Where to download the MYSQL Java Connector Library and get the jar file This article discuss 'how to connect Java and MYSQL using MYSQL connector' in Java. The article will give you view on downloading and installing MYSQL Java
mysql jsp - Java Beginners
mysql jsp  how to insert values to mysql? i want to insert values from a combo box to mysql... how to perform that. pls help me in urgent.  Hi friend, Plz give full source code where you having the problem
jsp, mysql - Java Beginners
jsp, mysql  i want to store / insert the selected value in the combo box (jsp), into the mysql. how to do it?... pls help me in urgent
how to migrate java db to mysql
how to migrate java db to mysql  I have an aplication,for migrating java db to mysql db.how it will done
MYSQL
MYSQL  How to create time and date based trigger in mysql   MySQL Time Trigger
Connecting to MYSQL Database in Java
Connecting to MYSQL Database in Java  I've tried executing the code...("MySQL Connect Example."); Connection conn = null; String url = "jdbc:mysql://localhost/"; String dbName = "textbook"; String driver
mysql with jsp - Java Beginners
mysql with jsp  i wanted to insert a combo box value to mysql table usgin jsp. how to perform that. can anybody help me in urgent.  Hi friend, Code to help in solving the problem : Select
mysql
mysql  how to open\import table in .dbf format in mysql
Maven Dependency mysql-connector-java >> 2.0.14
You should include the dependency code given in this page to add Maven Dependency of mysql >> mysql-connector-java version2.0.14 in your project
Maven Dependency mysql-connector-java >> 3.0.10
You should include the dependency code given in this page to add Maven Dependency of mysql >> mysql-connector-java version3.0.10 in your project
Maven Dependency mysql-connector-java >> 3.0.8
You should include the dependency code given in this page to add Maven Dependency of mysql >> mysql-connector-java version3.0.8 in your project
Maven Dependency mysql-connector-java >> 3.1.11
You should include the dependency code given in this page to add Maven Dependency of mysql >> mysql-connector-java version3.1.11 in your project
Maven Dependency mysql-connector-java >> 3.1.12
You should include the dependency code given in this page to add Maven Dependency of mysql >> mysql-connector-java version3.1.12 in your project
Maven Dependency mysql-connector-java >> 3.1.13
You should include the dependency code given in this page to add Maven Dependency of mysql >> mysql-connector-java version3.1.13 in your project
Maven Dependency mysql-connector-java >> 3.1.14
You should include the dependency code given in this page to add Maven Dependency of mysql >> mysql-connector-java version3.1.14 in your project
Maven Dependency mysql-connector-java >> 5.0.2
You should include the dependency code given in this page to add Maven Dependency of mysql >> mysql-connector-java version5.0.2 in your project
Maven Dependency mysql-connector-java >> 5.0.3
You should include the dependency code given in this page to add Maven Dependency of mysql >> mysql-connector-java version5.0.3 in your project
Maven Dependency mysql-connector-java >> 5.0.4
You should include the dependency code given in this page to add Maven Dependency of mysql >> mysql-connector-java version5.0.4 in your project
Maven Dependency mysql-connector-java >> 5.0.5
You should include the dependency code given in this page to add Maven Dependency of mysql >> mysql-connector-java version5.0.5 in your project
Maven Dependency mysql-connector-java >> 5.0.7
You should include the dependency code given in this page to add Maven Dependency of mysql >> mysql-connector-java version5.0.7 in your project
Maven Dependency mysql-connector-java >> 5.0.8
You should include the dependency code given in this page to add Maven Dependency of mysql >> mysql-connector-java version5.0.8 in your project
Maven Dependency mysql-connector-java >> 5.1.1
You should include the dependency code given in this page to add Maven Dependency of mysql >> mysql-connector-java version5.1.1 in your project
Maven Dependency mysql-connector-java >> 5.1.10
You should include the dependency code given in this page to add Maven Dependency of mysql >> mysql-connector-java version5.1.10 in your project
Maven Dependency mysql-connector-java >> 5.1.11
You should include the dependency code given in this page to add Maven Dependency of mysql >> mysql-connector-java version5.1.11 in your project
Maven Dependency mysql-connector-java >> 5.1.12
You should include the dependency code given in this page to add Maven Dependency of mysql >> mysql-connector-java version5.1.12 in your project
Maven Dependency mysql-connector-java >> 5.1.13
You should include the dependency code given in this page to add Maven Dependency of mysql >> mysql-connector-java version5.1.13 in your project
Maven Dependency mysql-connector-java >> 5.1.14
You should include the dependency code given in this page to add Maven Dependency of mysql >> mysql-connector-java version5.1.14 in your project
Maven Dependency mysql-connector-java >> 5.1.15
You should include the dependency code given in this page to add Maven Dependency of mysql >> mysql-connector-java version5.1.15 in your project
Maven Dependency mysql-connector-java >> 5.1.16
You should include the dependency code given in this page to add Maven Dependency of mysql >> mysql-connector-java version5.1.16 in your project
Maven Dependency mysql-connector-java >> 5.1.17
You should include the dependency code given in this page to add Maven Dependency of mysql >> mysql-connector-java version5.1.17 in your project
Maven Dependency mysql-connector-java >> 5.1.18
You should include the dependency code given in this page to add Maven Dependency of mysql >> mysql-connector-java version5.1.18 in your project
Maven Dependency mysql-connector-java >> 5.1.19
You should include the dependency code given in this page to add Maven Dependency of mysql >> mysql-connector-java version5.1.19 in your project
Maven Dependency mysql-connector-java >> 5.1.2
You should include the dependency code given in this page to add Maven Dependency of mysql >> mysql-connector-java version5.1.2 in your project

Ads