7
我使用Eclipses數據源瀏覽器將Web應用程序連接到數據庫時遇到問題。無法將應用程序連接到數據庫
這是我做過什麼:
也許我錯了配置的驅動程序。這是我如何配置eclipse Helios的驅動程序定義。窗口 - >首選項 - > DataManagement-> Conectivity->驅動程序定義:
我能夠啓動應用程序服務器,甚至訪問throgh瀏覽器應用程序。但我無法與數據庫進行交互。這是Web應用程序的配置文件什麼樣子:
的persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="jdbc/GroupBuySystem">
<class>entities.Administ</class>
<class>entities.Buyer</class>
<class>entities.Comment</class>
<class>entities.Log</class>
<class>entities.Offer</class>
<class>entities.Seller</class>
</persistence-unit>
</persistence>
太陽resources.xml中
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE resources PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 Resource Definitions //EN" "http://www.sun.com/software/appserver/dtds/sun-resources_1_3.dtd">
<resources>
<jdbc-resource enabled="true" jndi-name="jdbc/myDatasource" object-type="user" pool-name="Derby_groupbuydb_userPool"/>
<jdbc-connection-pool allow-non-component-callers="false" associate-with-thread="false" connection-creation-retry-attempts="0" connection-creation-retry-interval-in-seconds="10" connection-leak-reclaim="false" connection-leak-timeout-in-seconds="0" connection-validation-method="auto-commit" datasource-classname="org.apache.derby.jdbc.ClientDataSource" fail-all-connections="false" idle-timeout-in-seconds="300" is-connection-validation-required="false" is-isolation-level-guaranteed="true" lazy-connection-association="false" lazy-connection-enlistment="false" match-connections="false" max-connection-usage-count="0" max-pool-size="32" max-wait-time-in-millis="60000" name="Derby_groupbuydb_userPool" non-transactional-connections="false" pool-resize-quantity="2" res-type="javax.sql.DataSource" statement-timeout-in-seconds="-1" steady-pool-size="8" validate-atmost-once-period-in-seconds="0" wrap-jdbc-objects="false">
<property name="serverName" value="localhost"/>
<property name="PortNumber" value="1527"/>
<property name="DatabaseName" value="groupbuydb"/>
<property name="User" value="user"/>
<property name="Password" value="pwd"/>
<property name="URL" value="jdbc:derby://localhost:1527/groupbuydb;create=true"/>
<property name="driverClass" value="org.apache.derby.jdbc.ClientDriver"/>
</jdbc-connection-pool>
</resources>
我也想提一提,我開始使用此命令從控制檯數據庫:
C:\ glassfishv3 \ BIN>的asadmin啓動數據庫
我在做什麼錯?爲什麼我無法連接到數據庫?
+1的圖片 – Ophidian 2011-04-01 14:25:46
TNX :)我希望我找到解決這個問題我堅持的方式它和我不能繼續我的編程。任何想法的人? – sfrj 2011-04-01 14:28:43
你可以從另一個應用程序連接到服務器嗎?例如從'ij',或從[H2數據庫](http://h2database.com)的控制檯工具? – 2011-04-01 14:47:21