I run tomcat 7.0.47 in my windows, and there I have a connection to the Mysql database with the data stored in BlueHost. When I run it locally, it succeeds and does a conunction for the BlueHost database without any error. But when I try to deploy my war file in linux environment working with tomcat 7.0.42, it causes the following error:
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'
In addition, I imported tomcat.dbcp jar to an online server, since linux has some problems with this bank.
Also, Server is working if I donot follow connection pooling approach .
I can’t find out what could be the problem when merging?
Below is my file context.xml:
<Context antiJARLocking="true" path="/web_app">
<Resource
name="jdbc/DB"
auth="Container"
type="javax.sql.DataSource"
maxActive="100"
maxIdle="30"
maxWait="10000"
username="DBUser"
password="DBPassword"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://xx.xx.xx.xx:xx/DB_app?useUnicode=true&characterEncoding=UTF-8"/>
</Context>
web.xml:
<resource-ref>
<description>MySQL Datasource</description>
<res-ref-name>jdbc/DB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
DatabaseConnection.java:
public class Get_Database_Connection
{
static DataSource ds;
public static Connection con=null;
public static Connection get_DB_Connection() throws NamingException,SQLException
{
if(ds==null)
{
Context ctx = new InitialContext();
ds = (DataSource) ctx.lookup("java:comp/env/jdbc/DB");
return ds.getConnection();
}
else
{
return ds.getConnection();
}
}
}
source
share