课程: Hands-On Introduction: Java

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Construct account from data source

Construct account from data source - Java教程

课程: Hands-On Introduction: Java

Construct account from data source

- [Instructor] In this video, we'll construct an account object, that represents a specific account from our database. The steps to complete this task are similar to the ones from the last video, where we constructed a customer object. If you like, you can pause the video and work on the solution independently. (soft music) Within the data source class, let's create a new method called get account. So we'll say public static account get account and we'll ask them to provide us with the account id. Our SQL query should target the accounts table by account id. So we'll say string SQL equals and we'll go select everything from accounts where the id equals question mark. Let's declare an account object that will later initialize once we have the results from the database. So we'll call this account and for now we'll set this equal to null. Now, let's create a try with resources structure to connect to the database and…

内容