mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improve OracleExceptionSorter
This commit is contained in:
@@ -425,6 +425,10 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
|
||||
for (Filter filter : this.filters) {
|
||||
filter.configFromProperties(properties);
|
||||
}
|
||||
|
||||
if (exceptionSorter != null) {
|
||||
exceptionSorter.configFromProperties(properties);
|
||||
}
|
||||
}
|
||||
|
||||
this.connectProperties = properties;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.alibaba.druid.pool;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* An interface to allow for exception evaluation.
|
||||
@@ -29,4 +30,6 @@ public interface ExceptionSorter {
|
||||
* @return true or false if the exception is fatal.
|
||||
*/
|
||||
boolean isExceptionFatal(SQLException e);
|
||||
|
||||
void configFromProperties(Properties properties);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.alibaba.druid.pool.vendor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Properties;
|
||||
|
||||
import com.alibaba.druid.pool.ExceptionSorter;
|
||||
|
||||
@@ -49,5 +50,9 @@ public class InformixExceptionSorter implements ExceptionSorter, Serializable {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void configFromProperties(Properties properties) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.alibaba.druid.pool.vendor;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.Properties;
|
||||
|
||||
import com.alibaba.druid.mock.MockConnectionClosedException;
|
||||
import com.alibaba.druid.pool.ExceptionSorter;
|
||||
@@ -36,4 +37,7 @@ public class MockExceptionSorter implements ExceptionSorter {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void configFromProperties(Properties properties) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.alibaba.druid.pool.vendor;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.Properties;
|
||||
|
||||
import com.alibaba.druid.pool.ExceptionSorter;
|
||||
|
||||
@@ -60,5 +61,9 @@ public class MySqlExceptionSorter implements ExceptionSorter {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void configFromProperties(Properties properties) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.alibaba.druid.pool.vendor;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.Properties;
|
||||
|
||||
import com.alibaba.druid.pool.ExceptionSorter;
|
||||
|
||||
@@ -32,4 +33,7 @@ public class NullExceptionSorter implements ExceptionSorter {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void configFromProperties(Properties properties) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.alibaba.druid.pool.vendor;
|
||||
import java.io.Serializable;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import com.alibaba.druid.pool.ExceptionSorter;
|
||||
@@ -36,7 +37,11 @@ public class OracleExceptionSorter implements ExceptionSorter, Serializable {
|
||||
private Set<Integer> fatalErrorCodes = new HashSet<Integer>();
|
||||
|
||||
public OracleExceptionSorter(){
|
||||
String property = System.getProperty("druid.oracle.fatalErrorCodes");
|
||||
configFromProperties(System.getProperties());
|
||||
}
|
||||
|
||||
public void configFromProperties(Properties properties) {
|
||||
String property = properties.getProperty("druid.oracle.fatalErrorCodes");
|
||||
if (property != null) {
|
||||
String[] items = property.split("\\,");
|
||||
for (String item : items) {
|
||||
@@ -108,6 +113,7 @@ public class OracleExceptionSorter implements ExceptionSorter, Serializable {
|
||||
case 17024: // No data read
|
||||
case 17089: // internal error
|
||||
case 17409: // invalid buffer length
|
||||
case 17401: //
|
||||
case 17410: // No more data to read from socket
|
||||
case 17416: // FATAl
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.alibaba.druid.pool.vendor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Properties;
|
||||
|
||||
import com.alibaba.druid.pool.ExceptionSorter;
|
||||
|
||||
@@ -37,4 +38,8 @@ public class SybaseExceptionSorter implements ExceptionSorter, Serializable {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void configFromProperties(Properties properties) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package com.alibaba.druid.bvt.pool;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.Properties;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.alibaba.druid.pool.ExceptionSorter;
|
||||
import com.alibaba.druid.pool.vendor.MySqlValidConnectionChecker;
|
||||
@@ -98,5 +100,11 @@ public class DruidDataSourceTest4 extends TestCase {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configFromProperties(Properties properties) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Properties;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
@@ -40,6 +41,11 @@ public class DruidDataSourceTest_exceptionSorter extends TestCase {
|
||||
public boolean isExceptionFatal(SQLException e) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configFromProperties(Properties properties) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user