私は、Netbeans 6.5でMySQLデータベースとHibernateを使用してJava Webアプリケーションを開発しました。開発用データベースサーバと開発用アプリケーションサーバ(Tomcat 6)はどちらも開発用マシンにあります。すべてがうまくいく。アプリケーションはデータベースからデータを正しく取得します。Netbeans DevからTomcatプロダクションへ:DB接続が見つかりません
これで、プロダクションサーバーに移動する準備が整いました。ここでも、DBサーバーとアプリケーションサーバーは同じマシン上にあります。私はWARファイルをデプロイし、アプリケーションにアクセスしようとします。私は、静的なページが、例外を除いて、データベースのエラーを使用してサーブレットにアクセスすることができます。
org.hibernate.exception.JDBCConnectionException: Cannot open connection
私は問題は、データ・ソースについては知らないTomcatに関連するかなり確信しています。 Netbeansが私のためにこれを処理するかのようです。
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/EmployeeDirectory">
<Resource
name="jdbc/employeedirectory" auth="Container"
type="javax.sql.DataSource" username="EmployeeDir"
password="EmployeeDirectory" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://127.0.0.1:3306/EmployeeDirectory?autoReconnect=true"
maxActive="15" maxIdle="7"
validationQuery="Select 1" />
</Context>
のweb.xmlファイル:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- Omit Servlet Info -->
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/employeedirectory</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
と私は私が私ののcontext.xmlを与えたthis siteからいくつかのアドバイスを取ったので、私はRESOURCEエントリを追加する必要があるかもしれないことを読みましたhibernate.cfg.xmlの:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.datasource">java:comp/env/jdbc/employeedirectory</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- Omit other Mappings -->
<mapping class="EmployeeDirectory.data.PhoneNumber" resource="EmployeeDirectory/data/PhoneNumber.hbm.xml"/>
</session-factory>
</hibernate-configuration>
は今、私はorg.hibernate.HibernateException: Could not find datasource
エラーを取得します。
私は開発から運用に移行するための正しい道を進んでいますか?私は何が欠けていますか?