Hi every one, I have a java web Application and I use Tomcat connection pooling for it, this my setting:
<?xml version="1.0" encoding="UTF-8"?>
<Context path="" docBase="" debug="5" reloadable="true" crossContext="true">
<Resource name="jdbc/jdbcPool"
auth="Container"
type="javax.sql.DataSource"
maxActive="100"
maxIdle="30"
maxWait="10000"
username="root"
password="*******"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/dbname?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8"/>
</Context>
and my DAO:
public static Connection dbConnection() throws NamingException {
Context initContext;
DataSource ds = null;
Connection conn = null;
try {
initContext = new InitialContext();
Context envContext = (Context) initContext.lookup("java:/comp/env");
ds = (DataSource) envContext.lookup("jdbc/jdbcPool");
conn = ds.getConnection();
}catch (SQLException ex){
logger.error("SQLException Occurred in DAO.dbConnection() Method, Exception Message is: " + ex.getMessage(), ex);
}
catch (RuntimeException er){
logger.fatal("SQLException Occurred in DAO.dbConnection() Method, Exception Message is: " + er.getMessage(), er);
}catch(Exception rt){
logger.fatal("Exception Occurred in DAO.dbConnection() Method, Exception Message is: " + er.getMessage(), er);
}
return conn;
}
after that I want to use hibernate And I Refactor some part of my code but I want know can i use both of them in my application (I mean some part of my code use hibernate and some part use my DAO connection?) if yes what happen to that table not map in hibernate but some mapped table have relation to them? I don't know can explain my question right? if want more detail tell me.