<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">
<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>
                                <td>
                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="https://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>
                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px; -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
Re: Can't connect to MySQL in Java EE/JBoss application
</h3>
<span style="margin-bottom: 10px;">
created by <a href="https://community.jboss.org/people/krzemian">Sz Krze</a> in <i>Datasource Configuration</i> - <a href="https://community.jboss.org/message/757583#757583">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p>All right, I've repeated all the steps from the beginning as a fresh morning man and it worked. Still don't know why, but here're a few things that <strong>might've solved</strong> the problem:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Here're the steps I've followed (<span style="text-decoration: line-through;">I've just replicated them to be sure they're still not working</span>):</p><ol><li>Downloaded mysql-connector-java-5.0.8-bin.jar from <a class="jive-link-external-small" href="http://www.mysql.com/downloads/connector/j/5.0.html#downloads">http://www.mysql.com/downloads/connector/j/5.0.html#downloads</a> </li><li>Placed it in jboss-6.0.0.Final\server\default\lib</li><li>Created a new Connection Profile in Eclipse using Data Source Explorer (I don't know if that step is even necessary). In the wizard I've also created a new Driver Definition using the 5.0.8 connector. The ping succeeded and my database is visible from within the Data Source Explorer.</li><li>Generated -ds.xml file from the CP mentioned in 3) using File->New->Other...->JBoss Tools Web->JBoss Datasource (-ds.xml) (using AS5 format) and placed it in jboss-6.0.0.Final\server\default\deploy\Mysql_local-ds.xml <span style="text-decoration: line-through;">as well as project's META-INF\Mysql_local-ds.xml</span> (<strong>corrected: when I placed it in both places simultaneously, I received ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] Error installing to Real: (...) Caused by: java.lang.IllegalStateException: jboss.jca:name=MP01Datasource2,service=ManagedConnectionFactory is already installed.</strong></li><li>I've added the db's jar to build path usign [rmb on project]->Build Path->Configure Build Path...->Add Library->Connectivity Driver Definition and chose the one I've defined in 3)</li></ol><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>I have also deleted some old .jar deployments from my other test projects that got stuck in the workspace\.metadata\.plugins\org.jboss.ide.eclipse.as.core\JBoss_6.x_Runtime_Server1345902635716\deploy folder (supposedly due to incorrect shutdown), but I sincerely doubt that was what helped.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>I suppose the main cause might've been that as I was swapping the drivers and Driver Definitions (I've been moving from 5.1.sth to 5.0.8) I forgot to swap them in the pj's build path as well and involuntarily left the old one.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>My current <strong>persistence.xml</strong></p><p><?xml version="1.0" encoding="UTF-8"?></p><p><span><persistence xmlns="</span><a class="jive-link-external-small" href="http://java.sun.com/xml/ns/persistence" target="_blank">http://java.sun.com/xml/ns/persistence</a><span>" xmlns:xsi="</span><a class="jive-link-external-small" href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a><span>"</span></p><p><span>       xsi:schemaLocation="</span><a class="jive-link-external-small" href="http://java.sun.com/xml/ns/persistence" target="_blank">http://java.sun.com/xml/ns/persistence</a><span> </span><a class="jive-link-external-small" href="http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" target="_blank">http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd</a><span>"</span></p><p>       version="2.0"></p><p>  <persistence-unit name="mp" transaction-type="JTA"></p><p>    <jta-data-source>java:/MP01Datasource2</jta-data-source> </p><p>           <properties></p><p>       <!--s</p><p>       <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/></p><p>       --></p><p>       <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/></p><p>       <property name="hibernate.hbm2ddl.auto" value="create-drop"/></p><p>   </properties></p><p>  </persistence-unit></p><p></persistence></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><strong>Mysql_local-ds.xml</strong></p><p><?xml version="1.0" encoding="UTF-8"?></p><p><!DOCTYPE datasources</p><p>    PUBLIC "-//JBoss//DTD JBOSS JCA Config 1.5//EN"</p><p><span>    "</span><a class="jive-link-external-small" href="http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd" target="_blank">http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd</a><span>"></span></p><p><datasources></p><p>   </p><p>   <local-tx-datasource></p><p>      <jndi-name>MP01Datasource2</jndi-name></p><p>      <use-java-context>true</use-java-context></p><p>      <connection-url>jdbc:mysql://localhost:3306/mp</connection-url></p><p>      <driver-class>com.mysql.jdbc.Driver</driver-class></p><p>      <user-name>x</user-name></p><p>      <password>y</password></p><p>   </local-tx-datasource></p><p>    </p><p></datasources></p><p><strong><br/></strong></p><p><strong><br/></strong></p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Reply to this message by <a href="https://community.jboss.org/message/757583#757583">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in Datasource Configuration at <a href="https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2077">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>