Home » Core Java » sql » Page 10

sql

Scrollable ResultSet example

In this example we shall show you how to create and use a scrollable ResultSet. To use a scrollable ResultSet one should perform the following steps: Load the JDBC driver, using the forName(String className) API method of the Class. In this example we use the MySQL JDBC driver. Create a Connection to the database. Invoke the getConnection(String url, String user, ...

Read More »

Getting column names of a database table

With this example we are going to demonstrate how to get the column names of a database Table. In short, to get the column names of a database Table you should: Load the JDBC driver, using the forName(String className) API method of the Class. In this example we use the MySQL JDBC driver. Create a Connection to the database. Invoke ...

Read More »

Retrieve data example

This is an example of how to retrieve data from a database. Retrieving data from a database implies that you should: Load the JDBC driver, using the forName(String className) API method of the Class. In this example we use the MySQL JDBC driver. Create a Connection to the database. Invoke the getConnection(String url, String user, String password) API method of ...

Read More »

Update a table row example

In this example we shall show you how to update a Table row. To update a Table row one should perform the following steps: Load the JDBC driver, using the forName(String className) API method of the Class. In this example we use the MySQL JDBC driver. Create a Connection to the database. Invoke the getConnection(String url, String user, String password) ...

Read More »

Insert a row into a table example

With this example we are going to demonstrate how to insert a row into a table. We can insert rows to a table with the Statement or the PreparedStatement API, according to the frequency of inserted rows. In short, to insert a row into a table you should: Load the JDBC driver, using the forName(String className) API method of the ...

Read More »

List all database table names

This is an example of how to list all database table names. Listing all database table names implies that you should: Load the JDBC driver, using the forName(String className) API method of the Class. In this example we use the MySQL JDBC driver. Create a Connection to the database. Invoke the getConnection(String url, String user, String password) API method of ...

Read More »

Delete table example

In this example we shall show you how to delete a table. To delete a table one should perform the following steps: Load the JDBC driver, using the forName(String className) API method of the Class. In this example we use the MySQL JDBC driver. Create a Connection to the database. Invoke the getConnection(String url, String user, String password) API method ...

Read More »

Create table example

With this example we are going to create a table in Java. In short, to create a table you should: Load the JDBC driver, using the forName(String className) API method of the Class. In this example we use the MySQL JDBC driver. Create a Connection to the database. Invoke the getConnection(String url, String user, String password) API method of the ...

Read More »

Delete all table rows example

This is an example of how to delete all table rows in Java. In order to delete all rows of a table we can use TRUNCATE, because it does not generate rollback information and does not fire any delete triggers, so it is faster than DELETE. Deleting all table rows implies that you should: Load the JDBC driver, using the ...

Read More »

Delete table row example

In this example we shall show you how to delete a table row in Java. We can use the Statement and PreparedStatement API to delete a row in a table, according to how frequently a delete query is executed. To delete a row into a table one should perform the following steps: Load the JDBC driver, using the forName(String className) ...

Read More »