• JBoss/Wildfly 配置SQLserver服务器


    JBoss/Wildfly 配置SQLserver服务器

    http://blog.csdn.net/haitaolang/article/details/60467118


    wildfly standalone.xml 配置文件:

    xa-datasource:

    <xa-datasource jndi-name="java:jboss/datasources/sqlserver" pool-name="sqlserver" enabled="true" use-java-context="true">
    <xa-datasource-property name="URL">jdbc:sqlserver://211.100.75.235:1433;databaseName=IPTV;</xa-datasource-property>
    <driver>sqlserver</driver>
    <xa-pool>
    <min-pool-size>1</min-pool-size>
    <initial-pool-size>5</initial-pool-size>
    <max-pool-size>100</max-pool-size>
    <prefill>true</prefill>
    </xa-pool>
    <security>
    <user-name>xxx</user-name>
    <password>xxx</password>
    </security>
    </xa-datasource>


    <datasource jndi-name="java:jboss/datasources/sqlserver" pool-name="sqlserver" enabled="true" use-java-context="true">
    <connection-url>jdbc:sqlserver://211.100.75.235:1433;databaseName=IPTV;</connection-url>
    <driver>sqlserver</driver>
    <security>
    <user-name>xxx</user-name>
    <password>xxx</password>
    </security>
    </datasource>


    执行后遇到报错:

     javax.persistence.PersistenceException: org.hibernate.MappingException: No Dialect mapping for JDBC type: -9

    原因:Hibernate框架的方言(Dialect )没有数据库中数据类型nvarchar的映射,只有varchar类型的映射。所以在启动时出现此异常。

    解决方法:

    select  cast(area as varchar(200)) as area from xxx;

    把不符合列的类型强制转换。

    java.sql.Types对应的值请参考http://blog.sina.com.cn/s/blog_4f925fc30102ep0v.html
    
    java.sql.Types对应的sql server2008中的一些值:
    
    public final static int BIT   =  -7;
    
    public final static int TINYINT  =  -6;
    
    public final static int SMALLINT =   5;
    
    public final static int INTEGER  =   4;
    
    public final static int BIGINT   =  -5;
    
    public final static int FLOAT   =   6;
    
    public final static int REAL   =   7;
    
    public final static int DOUBLE   =   8;
    
    public final static int NUMERIC  =   2;
    
    public final static int DECIMAL  =   3;
    
    public final static int CHAR  =   1;
    
    public final static int VARCHAR  =  12;
    
    public final static int LONGVARCHAR  =  -1;
    
    public final static int DATE   =  91;
    
    public final static int TIME   =  92;
    
    public final static int TIMESTAMP  =  93;
    
    public final static int BINARY  =  -2;
    
    public final static int VARBINARY  =  -3;
    
    public final static int LONGVARBINARY  =  -4;
    
    public final static int NULL  =   0;
    
    public final static int OTHER  = 1111;
    
    public final static int JAVA_OBJECT         = 2000;
    
    public final static int DISTINCT            = 2001;
    
    public final static int STRUCT              = 2002;
    
    public final static int ARRAY               = 2003;
    
    public final static int BLOB                = 2004;
    
    public final static int CLOB                = 2005;
    
    public final static int REF                 = 2006;
    
    public final static int DATALINK = 70;
    
    public final static int BOOLEAN = 16;
    
    public final static int ROWID = -8;
    
    public static final int NCHAR = -15;
    
    public static final int NVARCHAR = -9;
    
    public static final int LONGNVARCHAR = -16;
    
    public static final int NCLOB = 2011;
    
    public static final int SQLXML = 2009;
    复制代码

    Hibernate SQL方言(hibernate.dialect):

    RDBMS

    Dialect

    DB2

    org.hibernate.dialect.DB2Dialect

    DB2 AS/400

    org.hibernate.dialect.DB2400Dialect

    DB2 OS390

    org.hibernate.dialect.DB2390Dialect

    PostgreSQL

    org.hibernate.dialect.PostgreSQLDialect

    MySQL5

    org.hibernate.dialect.MySQL5Dialect

    MySQL5 with InnoDB

    org.hibernate.dialect.MySQL5InnoDBDialect

    MySQL with MyISAM

    org.hibernate.dialect.MySQLMyISAMDialect

    Oracle(any version)

    org.hibernate.dialect.OracleDialect

    Oracle 9i

    org.hibernate.dialect.Oracle9iDialect

    Oracle 10g

    org.hibernate.dialect.Oracle10gDialect

    Oracle 11g

    org.hibernate.dialect.Oracle10gDialect

    Sybase

    org.hibernate.dialect.SybaseASE15Dialect

    Sybase Anywhere

    org.hibernate.dialect.SybaseAnywhereDialect

    Microsoft SQL Server 2000

    org.hibernate.dialect.SQLServerDialect

    Microsoft SQL Server 2005

    org.hibernate.dialect.SQLServer2005Dialect

    Microsoft SQL Server 2008

    org.hibernate.dialect.SQLServer2008Dialect

    SAP DB

    org.hibernate.dialect.SAPDBDialect

    Informix

    org.hibernate.dialect.InformixDialect

    HypersonicSQL

    org.hibernate.dialect.HSQLDialect

    H2 Database

    org.hibernate.dialect.H2Dialect

    Ingres

    org.hibernate.dialect.IngresDialect

    Progress

    org.hibernate.dialect.ProgressDialect

    Mckoi SQL

    org.hibernate.dialect.MckoiDialect

    Interbase

    org.hibernate.dialect.InterbaseDialect

    Pointbase

    org.hibernate.dialect.PointbaseDialect

    FrontBase

    org.hibernate.dialect.FrontbaseDialect

    Firebird

    org.hibernate.dialect.FirebirdDialect

  • 相关阅读:
    MSN、易趣、大旗被挂马 用户浏览后感染机器狗病毒 狼人:
    世界最大漏洞数据库发布最新研究报告 狼人:
    五角大楼最昂贵武器发展项目遭到黑客攻击 狼人:
    RSA呼吁厂商“创造性协作” 共同反击网络威胁 狼人:
    RSA2009:云计算服务如何保证安全? 狼人:
    黑客工具可将恶意软件隐藏于.Net框架 狼人:
    RSA安全大会将亮相25款热门安全产品 狼人:
    目录访问共享C#怎么访问共享目录
    代码下行Jquery结合Ajax和Web服务使用三层架构实现无刷新分页
    输出次数HDU2192:MagicBuilding
  • 原文地址:https://www.cnblogs.com/bigben0123/p/6874271.html
Copyright © 2020-2023  润新知