[exo-jcr-commits] exo-jcr SVN: r1883 - core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/impl.
do-not-reply at jboss.org
do-not-reply at jboss.org
Thu Feb 18 03:38:06 EST 2010
Author: sergiykarpenko
Date: 2010-02-18 03:38:06 -0500 (Thu, 18 Feb 2010)
New Revision: 1883
Modified:
core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/impl/HibernateServiceImpl.java
Log:
EXOJCR-485: NPE on wrong datasource fixed
Modified: core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/impl/HibernateServiceImpl.java
===================================================================
--- core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/impl/HibernateServiceImpl.java 2010-02-18 08:34:30 UTC (rev 1882)
+++ core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/impl/HibernateServiceImpl.java 2010-02-18 08:38:06 UTC (rev 1883)
@@ -123,11 +123,11 @@
try
{
- // check is there is datasource
+ // check is there is data source
String dataSourceName = conf_.getProperty("hibernate.connection.datasource");
if (dataSourceName != null)
{
- //detect with datasource
+ //detect dialect by data source
DataSource dataSource;
try
{
@@ -136,30 +136,28 @@
{
log_.error("DataSource is configured but not finded.", new Exception());
}
+ else
+ {
+ connection = dataSource.getConnection();
- connection = dataSource.getConnection();
-
- Dialect d = DialectFactory.buildDialect(new Properties(), connection);
- conf_.setProperty("hibernate.dialect", d.getClass().getName());
-
+ Dialect d = DialectFactory.buildDialect(new Properties(), connection);
+ conf_.setProperty("hibernate.dialect", d.getClass().getName());
+ }
}
catch (NamingException e)
{
log_.error(e.getMessage(), e);
}
-
}
else
{
-
String url = conf_.getProperty("hibernate.connection.url");
if (url != null)
{
- //detect with url
- //get driver class
-
+ //detect dialect by url
try
{
+ //load driver class
Class.forName(conf_.getProperty("hibernate.connection.driver_class")).newInstance();
}
catch (InstantiationException e)
@@ -184,7 +182,6 @@
Dialect d = DialectFactory.buildDialect(new Properties(), connection);
conf_.setProperty("hibernate.dialect", d.getClass().getName());
-
}
else
{
@@ -192,7 +189,6 @@
log_.error(e.getMessage(), e);
}
}
-
}
catch (SQLException e)
{
@@ -212,9 +208,7 @@
}
}
}
-
}
-
}
public void addPlugin(ComponentPlugin plugin)
More information about the exo-jcr-commits
mailing list