Jsf-jdbc-integration
提供:Dev Guides
JSF-JDBC統合
この記事では、JDBCを使用してJSFにデータベースを統合する方法を示します。
この例を実行するためのデータベース要件は次のとおりです。
S.No | Software & Description |
---|---|
1 |
オープンソースおよび軽量データベース |
2 |
PostgreSQL 9.1およびJDK 1.5以上のJDBCドライバー |
PostgreSQL JDBC4ドライバーjarをTomcat Webサーバーのlibディレクトリに配置します。
データベースSQLコマンド
応用例
JDBC統合をテストするテストJSFアプリケーションを作成しましょう。
Step | Description |
---|---|
1 | Create a project with a name helloworld under a package com.finddevguides.test as explained in the JSF - First Application chapter. |
2 | Create resources folder under src → main folder. |
3 | Create css folder under src → main → resources folder. |
4 | Create styles.css file under src → main → resources → css folder. |
5 | Modify styles.css file as explained below. |
6 | Modify pom.xml as explained below. |
7 | Create Author.java under package com.finddevguides.test as explained below. |
8 | Create UserData.java under package com.finddevguides.test as explained below. |
9 | Modify home.xhtml as explained below. Keep the rest of the files unchanged. |
10 | Compile and run the application to make sure the business logic is working as per the requirements. |
11 | Finally, build the application in the form of war file and deploy it in Apache Tomcat Webserver. |
12 | Launch your web application using appropriate URL as explained below in the last step. |
styles.css
pom.xml
Author.java
UserData.java
home.xhtml
すべての変更を完了したら、JSF-最初のアプリケーションの章で行ったようにアプリケーションをコンパイルして実行します。 すべてがアプリケーションで問題ない場合、次の結果が生成されます。