JDBC Example with MySQL
- Mapping
MySQL Data Types in Java
Data types of MySQL and Java programming language are not same, its need some mechanism for transferring data between an database using MySQL data types and a application using Java data types.
- Connecting to a MySQL Database in Java
In this section, you will learn how to connect the MySQL database with Java file. We need to establish a connection between MySQL and Java files so that we can use MySQL driver for MySQL.
- Creating a
Database in MySQL
After establishing the connection with MySQL database by using the JDBC driver, you will learn how we can create our database.
- Creating a Database Table
Here, providing you an example with code and it's description that helps you to create a database table in a database through the java file.
- Creating a MySQL Database Table to store Java Types
Dear user, consider a case where we need to store a java types in our database table. This section describes how to create a MySQL database table that stores all java types.
- Description of
Database Table
This section introduces you how to get the detailed information about the database table. As we all know that, table has some specific information like: field, type, null etc.
-
Deleting a Table from Database
This section describes how to delete a table from database. Java provide the facility for deleting a specific table from a given database with the help of some specified methods. Retrieving Tables from a Database
This section provides you a facility for retrieving tables from a specific database through an example. You have to know about a database that is a collection of data or information.Inserting values in MySQL database table
Here we are going to see, how we can insert values in the MySQL database table. We know that tables store data in rows and column format. After creating a database table, you insert the values in it.Retrieving All Rows from a Database Table
Here, you will learn how to retrieve all rows from a database table. You know that table contains or stores the data in rows and columns format. If you want to access the data from a table then you need to use some APIs and methods.- Count Rows from a
Database Table
After creating a database table, if we want to know number of rows in a table then we can get it very easily by using the simple database query.
Getting Column Names from a database table in Java
Here, providing you an example with code that retrieves all columns name in a specific database table. Sometimes, you need to know the number of columns and the names of the columns of the table then you can retrieve it with the help of this example.- Adding a New Column in
Database Table
In this jdbc tutorial program we are going to learn about adding a new column in database table. Sometimes it happens that we have created a table and forgets to add some important column name into it.
- Rename Column
Name of a Database Table
This section provides you an example with code for renaming a column name in a database table. As we know that each table keeps contents in rows and column format.
- Make Unique key
in a Column
In this section you will learn, how to define a unique key in a column of a database table. While declaring unique key in a column we should check whether this column is eligible to store a unique values or not because if the column has been declared as unique then it can't store a duplicate values.
- Remove Unique
Key in Database Table
In this section, we will see how to remove unique field of the particular column in a database table. We know that, any table stores data in the form of rows and columns.
- Arranging Records
of Database Table in Ascending Order
This section will provide you the facility for arranging the data of database table in ascending order. Firstly we should know what is the meaning of ascending order. The ascending order means an arrangement of data from smallest to largest number in sequence like: 3,6,8,19,21,.........
- Arranging Records
of Database Table in Descending Order
This section provides an example with code that arrange the records of database table in descending order. The descending order provides a way for arranging records from largest to smallest in a sequence like: 100,85,45,12,.........
- Sum of Specific Column
Data in a Database Table
This section describes how we can calculate the sum of specific column data in the database table. Consider an example of any university where we need to calculate the sum of numbers achieved by the student.
Deleting All Rows from a Database Table
Consider a case where we have been given one database table, now we have to delete all the rows from the table. This section describes for deleting all rows from a specific database table.Delete a Specific Row from a Database Table
Consider a case where we are creating a table and we have add some data in it. It may happen that we might add a wrong data in a row, now we need to delete that particular data. This can be done very easily , and in this section we are going to do the same that is, how to delete a specific row from a specific database table.- Delete a Column from
a Database Table
In this section, we are going to learn how to delete a column from a database table. We are not going to create a new table into, and we are expecting that you can make a table yourself.
Join tables in the specific database
In this section, we are going to consider how to join two or more tables in a specific database. For this you need to have two or more table in the database. If two or more tables are available in the database then Join operation is performed otherwise not.Join tables with the NATURAL LEFT JOIN operation
This section describes the NATURAL LEFT JOIN operation and how to retrieve data through it. In this operation we are going to retrieve data according to match the field name of another tables.Join tables with the NATURAL RIGHT JOIN operation
This section describes the NATURAL RIGHT JOIN operation of table in a specific database. This operation join tables on the basis of matching fields but priority will be given to the right table field values.Cross Join Tables in a Specific Database
This section introduces you to the cross join between two tables. The cross join operation retrieves data between two tables as a Cartesian product of set theory in mathematics. All data show to multiply by each rows.- Prepared
Statement Set Object
In JDBC tutorial we are going to learn about the PreparedStatement and how to use with setObject method.
- Statement
Batch Update
In this section we are going to learn about the batch update and how to use it. Here, we are providing an example with code to execute the statement in a batch. Batch updates means more than one statements are executed or updates simultaneously in the database.
- Prepared
Statement Batch Update
This section helps to use the prepared statement with batch update and we are going to provide an example that performs batch update facility.
- Select Records
Using Prepared Statement
In this section we will learn how to select the some specific records by using the PreparedStatement. We know that the PreparedStatement object represents a precompiled SQL statement.
- Update Records
using Prepared Statement
The JDBC provides you the facility for updating the records. In this JDBC tutorial we are going to learn about the process of updating the records by using the PreparedStatement.
- Inserting Records
using the Prepared Statement
In this section we are going to learn how will insert the records in the database table by using the PreparedStatement interface of java.sql package.
- Count Records using
the Prepared Statement
In this section we will learn how to count all records of the database table by using the PreparedStatement interface of java.sql package.
- Deleting Records
using the Prepared Statement
This section helps us for deleting the records from the database table by using the PreparedStatement interface of the java.sql package.
- Using the
Prepared Statement Twice Time
This JDBC tutorial helps us for using the PreparedStatement interface of java.sql package twice times in a program. According to our requirement we can use the PreparedStatement object one or more times in a program for different purposes.
- Set Data Types by
using Prepared Statement
In this section we are going to learn the method for setting data types (String, int, float and double) in the PreparedStatement interface of java.sql package.
- Set byte, short
and long data types by using the Prepared Statement
This tutorial teaches you the process of setting the byte, short and long data types in the PreparedStatement interface of the java.sql package.
- Prepared Statement
Set Big Decimal
In this JDBC section we are going to learn about the big decimal and how can be set it in the database table by using the PreparedStatement interface of java.sql package.
- Set Date by using the
Prepared Statement
This JDBC tutorial helps us for setting date in the database table by using the PreparedStatement interface of java.sql package.
- Set Time by using the
Prepared Statement
In this section you will learn about setting the time in database table by using the PreparedStatement interface of java.sql package. Suppose you want to insert the actual time in a table, here you will provide a setTime method for setting the time.
- Set Timestamp by
using the Prepared Statement
In this JDBC tutorial we will teach how to set the Timestamp in database table by using the PreparedStatement interface of java.sql package. If you want to insert the Timestamp in a table,here you will provide the setTimestamp method that added date and time in the database table by using the java.util.Date package.
-
Write Text File to Table
In this section, you will learn how to read the records of a simple text file and write (insert) into a simple table in MySQL database. All records are written in the simple text file and again, if you need to insert these records in tabular format the following example will provide the facility for writing this content. -
Copy Table in a MySQL Database
In this section, you will learn to copy one table to another in a same MySQL database.
-
Copy One Database Table to Another
In this section, you will learn to copy one database table to another database table. That means we copy one table to a different table but it contains a similar type of field or column.
-
Insert Data in
Table Using Stored Procedure
In this example we are inserting data into a table using stored procedure.
-
Inserting Image
in Database Table
In this section, you will learn to insert an image to the MySQL database table.
-
JDBC Mysql Connection String
In this Tutorial we want to explain you a code that makes you to understand JDBC MysqlConnection String.