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;
JBoss/Wildfly 配置SQLserver服务器

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

上一篇:诺基亚S40手机联系人导入安卓手机


下一篇:jboss jndi配置部分参数详解