!!!開発時と稼働時の接続情報は異なる
Java EE 7 の実装であるJBoss ToolsとWildFlyで開発する時の注意としては次です。
#開発時に使うDB接続は「Database Connections」で設定する。
#稼働時の接続方法は2通りある。以下のうち1を推奨。
##アプリケーションサーバー上(WildFlyのこと、以下APサーバー)で設定する。(WildFly上のデータソースとpersistence.xmlでの設定)
##アプリケーション個別で設定する(warファイルに含める)。(persistence.xmlとwebアプリケーション-ds.xmlでの設定)
共通した設定もこれ以前にあります。
!!!共通する設定
!!MySQLのJDBCドライバをダウンロードする
!APサーバー上に定義したデータソース経由でRDBに接続する場合 (推奨)
#5.1系の最新をダウンロードする。2016年4月時点では5.1.38。\\
 [https://dev.mysql.com/downloads/connector/j/]
#ダウンロードしたファイルを展開する。
#mysql-connector-java-5.1.38.jarファイルをeclipseフォルダの横並びに配置する。(配下ではなく)\\
 例えば、mysqljdbc\mysql-connector-java-5.1.38.jar
#APサーバー(WildFly)にjarファイルをデプロイする。(手順は後述)

!アプリケーション(warファイル内)で定義した設定でRDBに接続する場合
この方法の場合にはJDBCのjarファイルがAPサーバー上に毎回デプロイされます。APサーバー(WildFly)上のデータソース経由で接続したい場合にこの設定は不要です。\\
#プロジェクトのpom.xmlをエディタで開き、DependenciesタブでAddボタンを押す
#次のように入力する。
 [{Image src='mysql-dependency.png'}]
 Artifact Idは mysql-connector-java。Versionにはその時点での最新を記述する。
#pom.xmlファイルを保存する
#以下のフォルダ配下にjarファイルが出来ていればOK。\\
 *あなたのユーザーフォルダ\.m2\repository\mysql\mysql-connector-java
もしもファイルが出来ていない場合はpom.xmlの設定を見直した上で以下を実行する。
#Project Explorerでプロジェクトを選択して右ボタンクリック。
#Maven → Update Project を実行する。

!!!開発時のDB接続設定
!!Database ConnectionsにMySQLサーバーへの接続情報を設定する
#Window→Perspective → Open Perspective → Other を開く
#JPAを選択する

[{Image src='database-connections.png'}]
#開いた中のData Source Explorerをクリック
#Database Connectionsを右ボタンクリック
#Newをクリック

[{Image src='connection-profile.png'}]
#Connection Profile TypeからMySQLを選択する
#Nextボタンを押す。

[{Image src='driver-definition.png'}]
#Drivers選択リストの右にある「+」アイコンを押す。
#Name/Typeタブにて5.1(またはさらに新しいもの)をクリックする。
#表示された画面のDriver nameに「MySQL JDBC Driver5.1.38」と記入する。バージョン番号は適宜換える。
#JAR Listタブを押す。
#Driver Filesに表示されている「mysql-connector-java-5.1.0-bin.jar」を削除する。
#Add JAR/ZIP ボタンを押す。
#表示されたファイルオープンダイアログにてダウンロードしておいたmysql-connector-java-5.1.38.jarを選択する。
[{Image src='driver-jar-list.png'}]
#OKボタンを押す。
\\
[{Image src='driver-properties.png'}]
#上記画面のそれぞれで接続情報を入力する。
#Test Connectionボタンを押して「Ping Succeeded!」と表示されれば成功。エラーが表示された場合はDBが起動されているか、接続情報を誤っていないか確認する。
#Finishボタンを押す。
#下記画面が表示されれば完了。
[{Image src='database-connections-fin.png'}]

!!Javax.transaction APIをMavenに記述する
いや~、これはハマりました。どハマリです。この設定が必要だと判るのに1週間掛かりました!\\
この設定をしないと、CDI管理でのpersist()が出来ません。実行時に"Transaction is required to perform ・・・"
というエラーが出て、ずっと原因が判りませんでした。\\
CDI管理においては"@Transactional"アノテーションによるトランザクション指定が必要なことを理解してなかった事から来る大きな勘違いもありました。なまじSELECTは正しく動くので余計混乱して時間ロスが。\\
#CDI管理下のテーブル更新では@Transactionalアノテーションが必要。
#@Transactionalアノテーションをビルドするためには、Jboss Toolsに入っていないJavax.transaction APIの取得が必要。
ということを皆さんは忘れないよう注意して下さい。以下手順です。
#pom.xml の<dependencies>配下に以下を追加する。
%%prettify 
{{{
    <dependency>
        <groupId>javax.transaction</groupId>
        <artifactId>javax.transaction-api</artifactId>
        <version>1.2</version>
    </dependency>
}}}
/%
 だけです。
でも、Jboss Toolsにこれが入っていないのってなぜ???

!!jboss-web.xmlにエンコーディングを記述する
これもプチはまりでした。\\
SELECTする時の検索条件に日本語を書くと初回サブミット時だけ文字化けしたり、更新時の値として書くと毎回文字化けしたりと色々現象が出ましたがこれで解決しました。
#WEB-INF 直下に以下の内容の jboss-web.xml ファイルを配置する。
%%prettify 
{{{
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
	<default-encoding>UTF-8</default-encoding>
</jboss-web>
}}}
/%
当然の事ですが、エンコーディングの値(上記ではUTF-8)は各環境に合わせて換えて下さい。\\
また、このXMLファイルのネームスペースやスキーマロケーション(SchemaLocation)などの定義を書くとEclipse上でエラーが表示されます。エラーの内容を見ると、スキーマ定義ファイル(XSD)自体に誤りがあると怒っていますが、書かなくても動くので上記の通りでいいと思います。(整形式XML文書として使う)\\
参考 [https://github.com/jboss/metadata/blob/master/web/src/main/resources/schema/jboss-web_8_0.xsd]


!!!稼働時のDB接続設定
稼働時のDB接続設定は2通りあります。\\

!!アプリケーションサーバーの設定によってDBに接続する (推奨)
アプリケーションサーバー(WildFly 9.0.2.Final)上に定義されているデータソースを基にDBに接続する方法です。WildFly 10.0.0.Final でも同じです。WildFly 9.0.1.Final では画面構成が少し異なりますが基本的な手順は同じです。\\
この方法の場合、接続先リソースを持つファイル(persistence.xml)をどの環境でも同じにしておいて、
アプリケーションサーバー側の設定によって検証DBサーバーや本番DBサーバーなどの接続先を決めることが出来ます。\\

!JDBCドライバのデプロイ
#EclipseのServers窓にてWildFlyを起動する。
#ブラウザにて http://localhost:9990/console/ にアクセスする。
#[JBoss Toolsのインストールと設定|JBoss ToolsとWildFly9.0のインストールと設定]にて設定したユーザー/パスワードでログインする。
#以下の画面が表示される。
[{Image src='wildfly-console.png'}]
#上記画面左上のDeploymentsをクリックする。
\\
[{Image src='deployments1.png'}]
#Addボタンを押し、表示された画面で "Upload a new deployment" を選択し、"Next"ボタンを押す。
\\
[{Image src='deployments2.png'}]
#"ファイルを選択" ボタンを押す。
#ダウンロードしておいたjarファイルを選択する(この例ではmysql-connector-java-5.1.38.jar)。
#Nextボタンを押す。
\\
[{Image src='deployments3.png'}]
#Finishボタンを押す。
#次の画面が表示されれば完了。
[{Image src='deployments4.png'}]

!データソースを定義する
[{Image src='wildfly-ds1.png'}]
#Configurationタブ → Subsystems → Datasources → Non-XA → Addボタンを押す。
\\
[{Image src='wildfly-ds2.png'}]
#MySQL Datasourceを選択して"Next"ボタンを押す。
\\
[{Image src='wildfly-ds3.png'}]
#"Name"に自分が付けたい名前を入力する。
#"JNDI Name"にデータソース名を入力する。「java:jboss/datasources/自分が付けたい名前」\\
 ★このデータソース名をpersistence.xmlに後で記述する。
#Nextボタンを押す。
\\
[{Image src='wildfly-ds4.png'}]
#Detected Driverをクリックする。
#先ほどデプロイしたバージョンのJDBCドライバーのうち、mysql-connector-java-5.1.38.jar_com.mysql.jdbc.Driver_5_1 の方を選ぶ(Fabricでない方)。
#Nextボタンを押す。
\\
[{Image src='wildfly-ds5.png'}]
#"Connection URL"に jdbc:mysql://localhost:3306/DB名 を入力する。
#該当DBに接続可能なMySQLのユーザー名とパスワードを"Username"と"Password"に入力する。
#Test Connectionボタンを押す。
#"Successfully created JDBC connection."と表示されたら成功。
#OKボタンを押す。
\\
!!persistence.xmlにMySQLサーバーへの接続情報を設定する
!APサーバー上に定義したデータソース経由でRDBに接続する場合 (推奨)
この方法の場合は persistence.xml のみ定義します。\\
src/main/resources/META-INF/persistence.xmlをエディタで開き、Sourceタグに次のように設定します。\\
{{{
<persistence version="2.1"
   xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="
        http://xmlns.jcp.org/xml/ns/persistence
        http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
	<persistence-unit name="primary">
		<!-- If you are running in a production environment, add a managed 
         data source, this example data source is just for development and testing! -->
		<!-- The datasource is deployed as WEB-INF/jboss-javaee-webapp-ds.xml, you
         can find it in the source at src/main/webapp/WEB-INF/jboss-javaee-webapp-ds.xml -->
		<jta-data-source>java:jboss/datasources/jboss-javaee-webappDS</jta-data-source>
		<properties>
			<!-- Properties for Hibernate -->
			<property name="hibernate.hbm2ddl.auto" value="validate" />
			<property name="hibernate.show_sql" value="true" />
			<!-- added by ytp -->
			<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
		</properties>
	</persistence-unit>
</persistence>
}}}
||Name||Value||説明
|persistence-unit name|primary|任意の接続名。ここで定義した名前を@PersistenceContextアノテーションのunitName属性に記述する
|jta-data-source|java:jboss/datasources/任意の名前|WildFlyに定義したデータソース名。ここで定義したのと同じ文字列でWildFlyにも登録しておくこと。
|hibernate.hbm2ddl.auto|none|実行時にテーブルなどの作成を行うかどうか。規定値はcreate-drop。
|hibernate.show_sql|true|HibernateのログにSQLを出力する。規定値はfalse。
|hibernate.format_sql|false|Hibernateのログに出力するSQLを整形する。
|hibernate.dialect|org.hibernate.dialect.MySQLDialect|SQLの方言を指定する。この場合はMySQL。
\\
persistence.xmlのより詳しい内容はここが参考になります。
[Hibernateを使ったシンプルなJPA環境構築|http://trasis.jp/blog/lab/2008/09/hibernate-jpa%E7%92%B0%E5%A2%83%E6%A7%8B%E7%AF%89.html]
\\
!アプリケーション個別で設定する(warファイルに含める)場合
この方法の場合は、上記の persistence.xml と__アプリケーション用データソース定義ファイル(-ds.xml)__に設定します。\\
webapp/WEB-INF/アプリケーション名-ds.xmlをエディタで開き、下記のように設定します。\\
{{{
<datasources xmlns="http://www.jboss.org/ironjacamar/schema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.jboss.org/ironjacamar/schema http://docs.jboss.org/ironjacamar/schema/datasources_1_0.xsd">
    <!-- The datasource is bound into JNDI at this location. We reference 
        this in META-INF/persistence.xml -->
    <datasource jndi-name="java:jboss/datasources/jboss-javaee-webappDS"
        pool-name="jboss-javaee-webapp" enabled="true"
        use-java-context="true">
        <!-- these are defined on the wildfly datasource -->
        <connection-url>jdbc:mysql://localhost:3306/test</connection-url>
        <driver>jboss-javaee-webapp.war_com.mysql.jdbc.Driver_5_1</driver>
        <driver-class>com.mysql.jdbc.Driver</driver-class>
        <security>
            <user-name>testadmin</user-name>
            <password>pass</password>
        </security>
    </datasource>
</datasources>
}}}
||Name||Value||説明
|jndi-name|java:jboss/datasources/任意の名前|persistence.xmlで定義したデータソース名。この名前で紐付けられます。
|connection-url|jdbc:mysql://localhost:3306/test|ポート番号の後ろはSchema(DATABASE)名を書く。
|driver|jboss-javaee-webapp.war_com.mysql.jdbc.Driver_5_1|ドライバーバージョンが5.1の場合が左記。
|driver-class|com.mysql.jdbc.Driver|ドライバークラス。jarファイルの中の META-INF/services/java.sql.Driverファイルの中に記述されている。
|user-name|testuser|スキーマに接続するユーザー。
|password|pass|ユーザーのパスワード。
__■注意__\\
この-ds.xmlファイルを使った設定は将来使えなくなる可能性があります。\\
このファイルの設定方法を確認しながらWildFlyを起動している最中に、__-ds.xml will be deprecated__ というメッセージが表示されたことがありました。(設定の誤りによってあるエラーが発生した時だけ表示された)


----

1RSvjY  <a href="http://sdmwizhhajnd.com/">sdmwizhhajnd</a>, [url=http://lnafheqbopsv.com/]lnafheqbopsv[/url], [link=http://xstsslsiiwyt.com/]xstsslsiiwyt[/link], http://bvszravkjzlf.com/

--[ydrjqpxx|http://fpiadmytizou.com/], 15-8-2016 18:59


----

qxuEe6  <a href="http://xbdgbbvwekwu.com/">xbdgbbvwekwu</a>, [url=http://hddmqzvwwedk.com/]hddmqzvwwedk[/url], [link=http://ukikutdvbyag.com/]ukikutdvbyag[/link], http://iebqokiqkdua.com/

--[orhutu|http://lykdccswhmqz.com/], 15-8-2016 19:09


----

Ewnri6  <a href="http://nkgqfpqzntmk.com/">nkgqfpqzntmk</a>, [url=http://yyizsiceynfu.com/]yyizsiceynfu[/url], [link=http://ynzkhsmaxrwh.com/]ynzkhsmaxrwh[/link], http://rivbwgdypfmz.com/

--[tmiwlydebb|http://khnniwwraqio.com/], 15-8-2016 19:25


----

yHug1M  <a href="http://cobzqsvbsdij.com/">cobzqsvbsdij</a>, [url=http://uvghxhpymhbx.com/]uvghxhpymhbx[/url], [link=http://fnqfdebftbzi.com/]fnqfdebftbzi[/link], http://kzyzkfrezbgp.com/

--[pgeasqvtws|http://jnwlxcswwmec.com/], 15-8-2016 21:23


----

FwlS2G  <a href="http://fpujokfbjoim.com/">fpujokfbjoim</a>, [url=http://xfrbyxnyviqk.com/]xfrbyxnyviqk[/url], [link=http://uygcmmkjxgyr.com/]uygcmmkjxgyr[/link], http://vtwyixhffilm.com/

--[nxpgldkki|http://advclivjtwua.com/], 15-8-2016 21:46


----

ULgpbJ  <a href="http://zfcwapgkdmpv.com/">zfcwapgkdmpv</a>, [url=http://rsxhvuiapbqj.com/]rsxhvuiapbqj[/url], [link=http://ayddttdklrvz.com/]ayddttdklrvz[/link], http://ubxfzszdxbta.com/

--[enzjvxe|http://xzwctslcnwwn.com/], 15-8-2016 23:53


----

QsXZmB  <a href="http://bymxjficolpo.com/">bymxjficolpo</a>, [url=http://awblaowifebh.com/]awblaowifebh[/url], [link=http://layffvnenijr.com/]layffvnenijr[/link], http://holzrnvbhvng.com/

--[gfigbul|http://wsbmjfcwzwoy.com/], 16-8-2016 00:13


----

Remove card prix du viagra en allemagne  Bahrain, a majority Shi'ite country ruled by the Sunni al Khalifa family, has been buffeted by unrest since the start of the Arab Spring uprisings in 2011, with mostly Shi'ite Bahrainis agitating for democratic reforms and more say in government.
 levitra 20 mg wiki  Schumer and Higgins called on the FAA to propose U.S. training requirements at an upcoming meeting of the U.N. aviation body, the International Civil Aviation Organization (ICAO), which will convene Sept. 24 &#8211; Oct. 4.
 

--[Irvin|http://www.gabrielandodonovansfunerals.com/viagra-prices-walmart-pharmacy.pdf], 16-8-2016 01:24


----

Whereabouts in  are you from? nexium alternatives cheaper  Researchers from the CDC&rsquo;s Office of Smoking and Health used a market research firm to come up with a nationally representative panel of 5,903 smokers and 5,203 nonsmokers. Among the smokers, 78% saw at least one "Tips" ad on TV, 17% heard at least one ad on the radio, 8% saw one in print and 23% saw one online.
 buy cheap ezetimibe  Tannehill showed his passing ability and cool head to produce a game-winning drive of 13 plays and 75 yards, ending with a delightful one-yard floated pass to rookie tight end Dion Sims with 38 seconds left.
 

--[Renaldo|http://minimalissimo.com/levlen-ed-acne-reviews.pdf], 16-8-2016 01:24


----

Cool site goodluck :) does boss rhino gold work  But it could also point to increasing internal struggles between groups seeking to reopen Facebook and other social networking sites, and hard-liners in the Iranian establishment, who remain firmly in control of Internet access.
 kaufen-viagra69.com test  The complaints are a first step in the criminal process, allowing prosecutors to begin an investigation that can lead to charges. Announcing the step was unusual: typically prosecutors wait until charges are filed before making public statements.
 

--[Lawerence|http://gardenstateiron.com/new/can-u-drink-on-cialis.pdf], 16-8-2016 01:24


----

A Second Class stamp he generic name for cialis iskustva  Carl Riccadonna, a senior economist at Deutsche Bank Securities in New York, said new claims and the four-week average at pre-recession levels were consistent with a pick-up in the pace of hiring, if not in August, then some time in the next couple of months.
 kamagra online paypal
  But Lauda&rsquo;s strength strangely makes him look really good. His eyes seem to glint even bluer when I tell him this. He says, &ldquo;I&rsquo;ve learnt from my life experience. I think I was much less charismatic before.&rdquo; Rush portrays the young Lauda as very determined, practical and pragmatic. His personality was the opposite of the flamboyant catnip to all women, James Hunt. Actor Daniel Brühl, who played Lauda, had to have prosthetic teeth. He was known as &ldquo;The Rat&rdquo; for his protruding teeth, which you don&rsquo;t notice now.
 

--[Aurelio|http://universports.info/how-long-does-extagen-last.pdf], 16-8-2016 01:24


----

I have my own business s ject 60  Researchers at the University of Michigan based their study on of 3,310 women and 2,382 men. The analysis is the first to look at gender differences in depression rates in a large national sample, Martin says.
 viagra generico 100 mg prezzo  A marriage proposal&hellip; on a camping trip? It doesn&rsquo;t sound like the typically romantic set-up, but then, Josh Sutton is not a typical camper. Imagine a sky full of stars, a crackling campfire and a menu of crispy whitebait with garlic and smoky, stuffed trout (bartered for a few beers with a local fisherman). You might warm to the idea.
 

--[Elvis|http://www.offshore.ie/where-to-buy-omeprazole-40-mg.pdf], 16-8-2016 01:24


----

Insufficient funds bactrim and pregnancy  This in turns adds to delays in A & E needlessly and time wasted when nursing staff and doctors could be attending to patients who really are in need of help.
 

--[Pablo|http://www.pust.cz/forum/?sulfasalazine-side-effects-rheumatoid-arthritis], 16-8-2016 01:24


----

Could you tell me the dialing code for ? viagra dove si compra  The commission said it's tracking eight notable leaks, 10 other locations with some evidence of leaks, and 33 places where oilfield equipment appears damaged but no evidence of spills has been spotted. About 1,300 oil and gas wells remain shut down.
 buy cheap zetia  The Union of Communication Workers has been reviewing its privatisation strategy and, while still opposed to the flotation, has been attracted by the approach adopted by employees in Eircom, the Irish telecom monopoly sold off in 1999.
 

--[Anthony|http://www.oriental-cat-breeder.co.uk/olanzapine-0167.pdf], 16-8-2016 01:24