JDBC Example with MySQL

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.

JDBC Example with MySQL

JDBC Example with MySQL

     

  1. 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.

  2. 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. 
     
  3. 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.
      
  4. 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.
     
  5. 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.
      
  6. 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. 
     
  7. 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.

  8. 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.

  9. 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. 

  10. 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.

  11. 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.
     
  12. 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.

  13. 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.
      
  14. 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.
      
  15. 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.  
      
  16. 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.
     
  17. 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,.........
     
  18. 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,.........
     
  19. 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. 
      
  20. 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.

  21. 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.

  22. 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.
     
  23. 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.

  24. 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.

  25. 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.

  26. 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.

  27. Prepared Statement Set Object 
    In JDBC tutorial we are going to learn about the PreparedStatement and how to use with setObject method. 
      
  28. 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.
     
  29. 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.
      
  30. 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.
     
  31. 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.
     
  32. 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.
      
  33. 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.
      
  34. 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.
      
  35. 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.
      
  36. 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.
     
  37. 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.
      
  38. 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.

      
  39. 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.
     
  40. 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.
     
  41. 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.
     
  42. 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.

  43. Copy Table in a MySQL Database  
    In this section, you will learn to copy one table to another in a same MySQL database.
      

  44. 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. 
      

  45. Insert Data in Table Using Stored Procedure
    In this example we are inserting data into a table using stored procedure.
     
  46. Inserting Image in Database Table
    In this section, you will learn to insert an image to the MySQL database table. 
      
  47. JDBC Mysql Connection String
    In this Tutorial we want to explain you a code that makes you to understand JDBC MysqlConnection String.

Tutorials

  1. Mapping MySQL Data Types in Java
  2. Connecting to a MySQL Database in Java
  3. Creating a Database in MySQL
  4. Creating a Database Table
  5. Creating a MySQL Database Table to store Java Types
  6. Description of Database Table
  7. Deleting a Table from Database
  8. Retrieving Tables from a Database
  9. Inserting values in MySQL database table
  10. Retrieving All Rows from a Database Table
  11. Adding a New Column Name in Database Table
  12. Change Column Name of a Table
  13. Make Unique Column in Database Table
  14. Remove Unique Column in Database Table
  15. Arrange a Column of Database Table
  16. Arrange a Column of Database Table
  17. Sum of Column in a Database Table
  18. Deleting All Rows from a Database Table
  19. Delete a Specific Row from a Database Table
  20. Delete a Column from a Database Table
  21. Join tables in the specific database
  22. Join tables with the NATURAL LEFT JOIN operation
  23. Join tables with the NATURAL RIGHT JOIN operation
  24. Cross Join Tables in a Specific Database
  25. Prepared Statement Set Object
  26. Statement Batch Update
  27. Prepared Statement With Batch Update
  28. Select Records Using Prepared Statement
  29. Update Records using Prepared Statement
  30. Inserting Records using the Prepared Statement
  31. Count Records using the Prepared Statement
  32. Deleting Records using the Prepared Statement
  33. Using the Prepared Statement Twice
  34. Set Data Types by using Prepared Statement
  35. Set byte, short and long data types by using the Prepared Statement
  36. Prepared Statement Set Big Decimal
  37. Set Date by using the Prepared Statement
  38. Set Time by using the Prepared Statement
  39. Set Timestamp by using the Prepared Statement
  40. Copy Table in a MySQL Database