开发者社区 问答 正文

关于druid能否支持informix?报错

有没有大神能告知一下druid能否支持informix,目前我使用的druid是1.0.31,报错为DBType not support,求大神告知

展开
收起
爱吃鱼的程序员 2020-06-06 21:01:10 1053 分享 版权
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB
                        <p>估计很多人都没接触过informix(ps:我也没接触过),看druid的github上wiki里常见问题里第27条"<strong>Druid如何自动根据URL自动识别DriverClass的</strong>"里面有</p>
    
    jdbc:informix-sqlicom.informix.jdbc.IfxDriver

    估计是支持的,建议可以尝试使用druid的最新版本(目前是1.1.10)试试

                            是这个样子的,我更新了一下informix的驱动,后来启动的时候发现druid的主页实际上已将加载了这个驱动了,但是当我访问数据库的时候,依旧显示的是dbtype not support这个也是我不明白的地方,但是相同的配置我换了一下数据源HikariCP 就可以连接了
                        
    
                                回复 <a class="referer" target="_blank">@鱼在_水中游</a>  : 呃,我看了一下druid的初始化源码,驱动判断上是有informix的,你可以尝试一下在配置里写上DriverClass,而不是让他自动识别。另外我在源码里全搜索了一下not support,只找到了一个“getCreateTableScript dbType not support”,你可以看看是不是这个错并非druid报的而是你的dao层框架报的呢?
                        
    
                            但是目前我在使用的时候是显示不识别的,而且我换了多个版本了都是不行
                        
    
                        <p>请问楼主是否解决了,我现在也有这个问题org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection: dbType not support : informix,</p>
                    
    
                        <p>你是不是配置了druid的防火墙,因为我有次经历就是配置了防火墙,抛出了IllegalStateException dbType not support. 但是是支持监控的,查看datasource是有支持informix驱动的。</p> 
    
    while(true) {
                String realDriverClassName = driverClass.getName();
                if(!realDriverClassName.equals("com.mysql.jdbc.Driver") && !realDriverClassName.equals("com.mysql.cj.jdbc.Driver")) {
                    if(!realDriverClassName.equals("oracle.jdbc.OracleDriver") && !realDriverClassName.equals("oracle.jdbc.driver.OracleDriver")) {
                        if(realDriverClassName.equals("com.informix.jdbc.IfxDriver")) {
                            this.exceptionSorter = new InformixExceptionSorter();
                            break;
                        }

    但是在wallFilter的时候是没有对informix支持的。所以使用不支持的dbtype就抛IllegalStateException异常:

     if(this.dbType == null) {
                    this.dbType = JdbcUtils.getDbType(dataSource.getUrl(), (String)null);
                }
    
                if(!"mysql".equals(this.dbType) && !"mariadb".equals(this.dbType) && !"h2".equals(this.dbType) && !"presto".equals(this.dbType)) {
                    if(!"oracle".equals(this.dbType) && !"AliOracle".equals(this.dbType)) {
                        if(!"sqlserver".equals(this.dbType) && !"jtds".equals(this.dbType)) {
                            if(!"postgresql".equals(this.dbType) && !"edb".equals(this.dbType)) {
                                if(!"db2".equals(this.dbType)) {
                                    throw new IllegalStateException("dbType not support : " + this.dbType + ", url " + dataSource.getUrl());
                                }
    
    2020-06-06 21:01:29
    赞同 展开评论
问答分类:
问答地址: