Get the values of the columns automatically increment when Insert a record using JDBC
In some databases, the ID column of a table can be of type of which values automatically increase. Whenever you insert a record into a table, the value of this column is assigned by the database. You can not proactively assign a value to it. Your question in this case is how to obtain the ID of the inserted record.
In addition, some columns may not be invoilved in your Insert statement, in which case their values are assigned by default by a database. You want to get these values without creating a more query statement.
In PostGres, the column with Serial type will have values automatically increasing by database.
** Employees (PostGres) **
In MySQL, for a column to have automatically increasing value, it must be assigned the "Auto_Increase" attribute.
2- Get the value of ID column inserted
When you use JDBC to Insert a record to the database. The ID column can not be involved in the Insert statement. The position of ID column is defined by the design of such table. The first column has index 1 and the second column has index 2,...
The index of the ID column of the table isn't probably 1 (depending on the design of the table). In this case, you best access its value by name.
3- Get the values of many columns inserted
Some columns may not participate in your Insert statement . Their values are assigned by the database. You can get their values without creating a query statement.