<!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;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</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-&gt;New-&gt;Other...-&gt;JBoss Tools Web-&gt;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]-&gt;Build Path-&gt;Configure Build Path...-&gt;Add Library-&gt;Connectivity Driver Definition and chose the one I've defined in 3)</li></ol><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</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;">&#160;</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;">&#160;</p><p>My current <strong>persistence.xml</strong></p><p>&lt;?xml version="1.0" encoding="UTF-8"?&gt;</p><p><span>&lt;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>&#160;&#160;&#160;&#160;&#160;&#160; 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>&#160;&#160;&#160;&#160;&#160;&#160; version="2.0"&gt;</p><p>&#160; &lt;persistence-unit name="mp" transaction-type="JTA"&gt;</p><p>&#160;&#160;&#160; &lt;jta-data-source&gt;java:/MP01Datasource2&lt;/jta-data-source&gt; </p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;properties&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160; &lt;!--s</p><p>&#160;&#160;&#160;&#160;&#160;&#160; &lt;property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160; --&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160; &lt;property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160; &lt;property name="hibernate.hbm2ddl.auto" value="create-drop"/&gt;</p><p>&#160;&#160; &lt;/properties&gt;</p><p>&#160; &lt;/persistence-unit&gt;</p><p>&lt;/persistence&gt;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><strong>Mysql_local-ds.xml</strong></p><p>&lt;?xml version="1.0" encoding="UTF-8"?&gt;</p><p>&lt;!DOCTYPE datasources</p><p>&#160;&#160;&#160; PUBLIC "-//JBoss//DTD JBOSS JCA Config 1.5//EN"</p><p><span>&#160;&#160;&#160; "</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>"&gt;</span></p><p>&lt;datasources&gt;</p><p>&#160;&#160; </p><p>&#160;&#160; &lt;local-tx-datasource&gt;</p><p>&#160;&#160;&#160;&#160;&#160; &lt;jndi-name&gt;MP01Datasource2&lt;/jndi-name&gt;</p><p>&#160;&#160;&#160;&#160;&#160; &lt;use-java-context&gt;true&lt;/use-java-context&gt;</p><p>&#160;&#160;&#160;&#160;&#160; &lt;connection-url&gt;jdbc:mysql://localhost:3306/mp&lt;/connection-url&gt;</p><p>&#160;&#160;&#160;&#160;&#160; &lt;driver-class&gt;com.mysql.jdbc.Driver&lt;/driver-class&gt;</p><p>&#160;&#160;&#160;&#160;&#160; &lt;user-name&gt;x&lt;/user-name&gt;</p><p>&#160;&#160;&#160;&#160;&#160; &lt;password&gt;y&lt;/password&gt;</p><p>&#160;&#160; &lt;/local-tx-datasource&gt;</p><p>&#160;&#160;&#160; </p><p>&lt;/datasources&gt;</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>