Method of querying data from database using JDBC

*Resultset result set: encapsulates the results of queries using JDBC

* 1. The result set can be obtained by calling the executeQuery (SQL) method of the statement object

* 2. The resultset actually returns a data table with a pointer to the front of the first row of the data table,

*You can call the next () method to check whether the next line is valid. If it is valid, it returns true and the pointer moves down,

*It is equivalent to the combination of hasnext () and next () methods of the iterator object

* 3. When the pointer is positioned on a line, it can be obtained by calling the getxxx (index) method or the getxxx (columnname) method

*The value of each column. For example, getInt (1) gets the value of the first column, and getString ("name") gets the value of the column whose column name is "name"

The closed method writes an overloaded in tools

This is only the most basic operation of querying with JDBC. It may not be perfect in the future. It depends on your mood~

The above method of using JDBC to query data from the database is all the content shared by Xiaobian. I hope it can give you a reference and support more programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>