I'm moving my application to AWS ElasticBeanStalk and after spending countless hours trying to get my database connection working, I've repetitively failed.
First attempt,
I currently have an existing RDS database in use which I would like to continue use. I tried to connect to it with a plain old jdbc connection as followed.
<property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://masdfwe.czwweehqejmbr.us-east-1.rds.amazonaws.com:3306/project</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">xxxxx</property>
But found the following exception in the log.
Caused by: java.sql.SQLException: No suitable driver found for jdbc:mysql://masdfwe.czwweehqejmbr.us-east-1.rds.amazonaws.com:3306/project at java.sql.DriverManager.getConnection(DriverManager.java:596) at java.sql.DriverManager.getConnection(DriverManager.java:187) at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.getConnection(DriverManagerConnectionProviderImpl.java:192) at org.hibernate.internal.AbstractSessionImpl$NonContextualJdbcConnectionAccess.obtainConnection(AbstractSessionImpl.java:278) at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:297) ... 125 more
The mysql driver is deff in the lib directory, so I'm not sure why I'm seeing this exception.
Do I need to create a JNDI connection? If so, how do I go about altering the configuration files in tomcat7 on ElasticBeanStalk? Am I suppose to ssh into the ec2 instance, or do I do it into the ElasticBeanStalk instance?
Would I use something like this in my hibernate.cfg.xml
file?
<property name="hibernate.connection.datasource">java:comp/env/jdbc/project</property>
web.xml
<resource-ref>
<description>MyDatabase Description</description>
<res-ref-name>jdbc/project</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
I'm just not sure where or what I'm suppose to be configuring. Any help would be appreciated, I'm very confused.
Thanks in advance.