title: persistence exception on database connection using glassfish
body: <p>I'm new to glass-fish &amp; persistence and while trying to run a query on MySQL database in my machine i get the following error:    </p>
  
  <blockquote>
    <p>Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException
    Internal Exception: java.sql.SQLException: No database selected
    Error Code: 1046</p>
  </blockquote>
  
  <p>before running the server i made sure that the server configuration are done using this guide : <a href="http://dev.mysql.com/doc/refman/5.1/en/connector-j-usagenotes-glassfish-config.html" rel="nofollow">mysql site manual for using connector with glassfish</a>, and configured my persistence.xml like this:  </p>
  
  <pre><code>&lt;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"&gt;
  &lt;persistence-unit name="StudentRecipieWebsite" transaction-type="RESOURCE_LOCAL"&gt;
      &lt;non-jta-data-source&gt;jdbc/mySql&lt;/non-jta-data-source&gt;
      &lt;class&gt;il.musehunter.studentRecipes.dbModel.Image&lt;/class&gt;
      &lt;class&gt;il.musehunter.studentRecipes.dbModel.Ingrediant&lt;/class&gt;
      &lt;class&gt;il.musehunter.studentRecipes.dbModel.Recipe&lt;/class&gt;
      &lt;class&gt;il.musehunter.studentRecipes.dbModel.User&lt;/class&gt;
      &lt;properties&gt;
          &lt;property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/recipes_data"/&gt;
          &lt;property name="javax.persistence.jdbc.user" value="root"/&gt;
          &lt;property name="javax.persistence.jdbc.password" value="moshe1475"/&gt;
          &lt;property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/&gt;
          &lt;property name="eclipselink.jdbc.batch-writing" value="JDBC"/&gt;
      &lt;/properties&gt;
  &lt;/persistence-unit&gt;
  </code></pre>
  
  <p></p>
  
  <p>I'm really new to this and does not have a clue to what i should do next so any help would be very appreciated.</p>
  
  <p>edit:</p>
  
  <p>adding part of the domain.xml from my glassfish server  :</p>
  
  <pre><code>&lt;applications&gt;
  &lt;application context-root="/StudentRecipieWebsite" location="${com.sun.aas.instanceRootURI}/applications/StudentRecipieWebsite/" name="StudentRecipieWebsite" object-type="user"&gt;
    &lt;property name="appLocation" value="${com.sun.aas.instanceRootURI}/applications/__internal/StudentRecipieWebsite/StudentRecipieWebsite.war"&gt;&lt;/property&gt;
    &lt;property name="org.glassfish.ejb.container.application_unique_id" value="89812698949156864"&gt;&lt;/property&gt;
    &lt;property name="org.glassfish.persistence.app_name_property" value="StudentRecipieWebsite"&gt;&lt;/property&gt;
    &lt;property name="defaultAppName" value="StudentRecipieWebsite"&gt;&lt;/property&gt;
    &lt;module name="StudentRecipieWebsite"&gt;
      &lt;engine sniffer="ejb"&gt;&lt;/engine&gt;
      &lt;engine sniffer="security"&gt;&lt;/engine&gt;
      &lt;engine sniffer="jpa"&gt;&lt;/engine&gt;
      &lt;engine sniffer="web"&gt;&lt;/engine&gt;
    &lt;/module&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p></p>
  
  <p>and:</p>
  
  <pre><code>&lt;resources&gt;
  &lt;jdbc-resource pool-name="__TimerPool" jndi-name="jdbc/__TimerPool" object-type="system-admin"&gt;&lt;/jdbc-resource&gt;
  &lt;jdbc-resource pool-name="DerbyPool" jndi-name="jdbc/__default"&gt;&lt;/jdbc-resource&gt;
  &lt;jdbc-connection-pool datasource-classname="org.apache.derby.jdbc.EmbeddedXADataSource" res-type="javax.sql.XADataSource" name="__TimerPool"&gt;
    &lt;property name="databaseName" value="${com.sun.aas.instanceRoot}/lib/databases/ejbtimer"&gt;&lt;/property&gt;
    &lt;property name="connectionAttributes" value=";create=true"&gt;&lt;/property&gt;
  &lt;/jdbc-connection-pool&gt;
  &lt;jdbc-connection-pool is-isolation-level-guaranteed="false" datasource-classname="org.apache.derby.jdbc.ClientDataSource" res-type="javax.sql.DataSource" name="DerbyPool"&gt;
    &lt;property name="PortNumber" value="1527"&gt;&lt;/property&gt;
    &lt;property name="Password" value="APP"&gt;&lt;/property&gt;
    &lt;property name="User" value="APP"&gt;&lt;/property&gt;
    &lt;property name="serverName" value="localhost"&gt;&lt;/property&gt;
    &lt;property name="DatabaseName" value="sun-appserv-samples"&gt;&lt;/property&gt;
    &lt;property name="connectionAttributes" value=";create=true"&gt;&lt;/property&gt;
  &lt;/jdbc-connection-pool&gt;
  &lt;jdbc-connection-pool datasource-classname="com.mysql.jdbc.jdbc2.optional.MysqlDataSource" res-type="javax.sql.DataSource" name="MySQLConnPool"&gt;
    &lt;property name="portNumber" value="3306"&gt;&lt;/property&gt;
    &lt;property name="databaseName" value="recipes_data"&gt;&lt;/property&gt;
    &lt;property name="serverName" value="localhost"&gt;&lt;/property&gt;
    &lt;property name="user" value="root"&gt;&lt;/property&gt;
    &lt;property name="password" value="moshe1475"&gt;&lt;/property&gt;
    &lt;property name="URL" value="jdbc:mysql://:3306/"&gt;&lt;/property&gt;
  &lt;/jdbc-connection-pool&gt;
  &lt;jdbc-resource pool-name="MySQLConnPool" description="" jndi-name="jdbc/mySql"&gt;&lt;/jdbc-resource&gt;&lt;/resources&gt;
  </code></pre>