- Scala for Data Science
- Pascal Bugnion
- 185字
- 2021-07-23 14:33:10
JDBC summary
We now have an overview of JDBC. The rest of this chapter will concentrate on writing abstractions that sit above JDBC, making database accesses feel more natural. Before we do this, let's summarize what we have seen so far.
We have used three JDBC classes:
- The
Connection
class represents a connection to a specific SQL database. Instantiate a connection as follows:import java.sql._ Class.forName("com.mysql.jdbc.Driver")val connection = DriverManager.getConnection( "jdbc:mysql://127.0.0.1:3306/test", "root", // username when connecting "" // password )
Our main use of
Connection
instances has been to generatePreparedStatement
objects:connection.prepareStatement("SELECT * FROM physicists")
- A
PreparedStatement
instance represents a SQL statement about to be sent to the database. It also represents the template for a SQL statement with placeholders for values yet to be filled in. The class exposes the following methods: - A
ResultSet
instance represents a set of rows returned by aSELECT
orSHOW
statement.ResultSet
exposes methods to access fields in the current row:
The ResultSet
instance exposes the .next
method to move to the next row; .next
returns true
until the ResultSet
has advanced to just beyond the last row.
推薦閱讀
- 極簡算法史:從數學到機器的故事
- ASP.NET Core:Cloud-ready,Enterprise Web Application Development
- Vue.js設計與實現
- 解構產品經理:互聯網產品策劃入門寶典
- Docker進階與實戰
- Machine Learning with R Cookbook(Second Edition)
- 機械工程師Python編程:入門、實戰與進階
- Python高效開發實戰:Django、Tornado、Flask、Twisted(第2版)
- Visual C
- Hands-On Swift 5 Microservices Development
- Java程序設計
- MongoDB,Express,Angular,and Node.js Fundamentals
- NoSQL數據庫原理
- H5+移動營銷設計寶典
- Python高性能編程(第2版)