Sybase datatype Issue
2012-09-14 20:55
302 查看
Sybase 数据类型
1. 首先我们来关注下Sybase官网对应的java数据类型映射关系
参照:http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.help.ase_15.0.java/html/java/java138.htm
2. 第一次在项目中使用sybase, 所以没有什么经验,所以查了上面的数据类型后开始项目
有这样一个表:
create table ***(
TASKID numeric(10,0)
TASKNAME varchar(255)
FILESIZE numeric(10,2)
)
由上面的类型表可以见到
numeric 对应 java.math.BigDecimal
所以在执行sql为其设置参数代码如下:
setIntArgument(1, taskId);
setStringArgument(2,filepath);
setDecimalArgument(3, new BigDecimal(fileSize/1000d));
本以为可以顺利执行并返回结果,可是往往事与愿违,没有任何 错误以及异常。苦想很久,最后直接debug看到:
ClassNotFoundException:
arg0: com.sybase.jdbc3.tds.SybBigDecimal 但是去Sybase提供的驱动包中很显然可以找到,神奇之处。最后果断换掉,
利用
setDoubleArgument(3, fileSize/1000d); 通过,真是好玩啊
类似的问题还有:
DateTime - Timestamp
ClassnotFoundException:
com.sybase.jdbc3.jdbc.ErrorMessage
com.sybase.jdbc3.tds.TdsDateTime
Syabse的开发人员就是牛啊,居然都不用debug就能开发出这样的数据库来,真是厉害,程序员真是伤不起啊。
1. 首先我们来关注下Sybase官网对应的java数据类型映射关系
参照:http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.help.ase_15.0.java/html/java/java138.htm
SQL datatype | Corresponding Java datatypes | |
---|---|---|
Simply mappable | Object mappable | |
char/unichar | java.lang.String | |
nchar | java.lang.String | |
varchar/univarchar | java.lang.String | |
nvarchar | java.lang.String | |
text | java.lang.String | |
numeric | java.math.BigDecimal | |
decimal | java.math.BigDecimal | |
money | java.math.BigDecimal | |
smallmoney | java.math.BigDecimal | |
bit | boolean | Boolean |
tinyint | byte | Integer |
smallint | short | Integer |
integer | int | Integer |
bigint | java.math.BigInteger | |
unsigned smallint | int | Integer |
unsigned int | long | Integer |
unsigned bigint | java.math.BigInteger | |
real | float | Float |
float | double | Double |
double precision | double | Double |
binary | byte[] | |
varbinary | byte[] | |
datetime | java.sql.Timestamp | |
smalldatetime | java.sql.Timestamp | |
date | java.sql.Date | |
time | java.sql.Time |
有这样一个表:
create table ***(
TASKID numeric(10,0)
TASKNAME varchar(255)
FILESIZE numeric(10,2)
)
由上面的类型表可以见到
numeric 对应 java.math.BigDecimal
所以在执行sql为其设置参数代码如下:
setIntArgument(1, taskId);
setStringArgument(2,filepath);
setDecimalArgument(3, new BigDecimal(fileSize/1000d));
本以为可以顺利执行并返回结果,可是往往事与愿违,没有任何 错误以及异常。苦想很久,最后直接debug看到:
ClassNotFoundException:
arg0: com.sybase.jdbc3.tds.SybBigDecimal 但是去Sybase提供的驱动包中很显然可以找到,神奇之处。最后果断换掉,
利用
setDoubleArgument(3, fileSize/1000d); 通过,真是好玩啊
类似的问题还有:
DateTime - Timestamp
ClassnotFoundException:
com.sybase.jdbc3.jdbc.ErrorMessage
com.sybase.jdbc3.tds.TdsDateTime
Syabse的开发人员就是牛啊,居然都不用debug就能开发出这样的数据库来,真是厉害,程序员真是伤不起啊。
相关文章推荐
- Sybase data type
- Jet 4.0 ODBC DataType 映射
- FW: GUID Vs Int data type as primary key
- WCF Data Contract之KnownType
- php在form表单ENCTYPE="multipart/form-data" 不用转换编码
- UNKNOWN as the Datatype when generated(MS ACCESS) -----MyGeneration
- 解决Excel错误0x80028018 (TYPE_E_INVDATAREAD)
- Multithreaded simple data type access and atomic variables
- org.springframework.data.mapping.PropertyReferenceException: No property created found for type
- Can not issue data manipulation statements with executeQuery()
- enctype="multipart/form-data" 文件上传
- TYPES与DATA TYPE与LIKE 区别
- struts中post方式上传文件,enctype="multipart/form-data",request.getParameter("file") 是null的问题分析
- Unknown integral data type for ids : java.lang.String; nested exception is org.hibernate.id.Identifi
- 出现ORA-03115:unsupported network datatype or representation错误的解决方法
- java 数据类型(data type)
- jQuery的Ajax中dataType选项用于设置返回值类型
- 蓝牙广播【广播报文类型】【AD type定义】【Advertising Interval】【EXTENDED INQUIRY RESPONSE DATA FORMAT】
- form表单中的enctype="multipart/form-data
- Posted content type isn't multipart/form-data