Unable to connect the application to the database

I have a problem connecting my web application to a database using Eclipses datasource explorer.

This is what I did:

enter image description here

Perhaps I configured the wrong driver. This is how I configured the driver definition from eclipse Helios. Window-> Preferences-> DataManagement-> Conectivity-> Driver Definitions:

one

enter image description here

2

enter image description here

3

enter image description here

4

enter image description here

I can start the application server and even access the application in the browser. But I can not interact with db. Here's what the webapp configuration files look like:

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> 

Sun-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> 

I also want to mention that I start the database from the console using this command:

C: \ glassfishv3 \ bin> asadmin start-database

enter image description here

What am I doing wrong? Why can not I connect to the database?

+7
source share
1 answer

You have the wrong jar file. Use derbyclient.jar and not derby.jar for your driver.

derby.jar for derby in native mode. derbyclient.jar is for network / server mode and what you defined in the connection string:

 <property name="URL" value="jdbc:derby://localhost:1527/groupbuydb;create=true"/> 
+6
source

All Articles