Data Type Mapping
abcolson Jan 4, 2005 9:52 PMGreetings List,
I am using jboss-4.0.0RC2 with MS Access. I had to create my own mappings in standardjbosscmp-jdbc.xml (If anyone knows of one that already exists that may solve alot of my problems).
In the type mapping I have the defaults set up as
<jbosscmp-jdbc> <defaults> <datasource>java:/DefaultDS</datasource> <datasource-mapping>MS ACCESS</datasource-mapping> <create-table>true</create-table> <remove-table>false</remove-table> <read-only>false</read-only> <read-time-out>300000</read-time-out> <row-locking>false</row-locking> <pk-constraint>true</pk-constraint> <fk-constraint>false</fk-constraint> <preferred-relation-mapping>foreign-key</preferred-relation-mapping> <read-ahead> <strategy>on-load</strategy> <page-size>1000</page-size> <eager-load-group>*</eager-load-group> </read-ahead> <list-cache-max>1000</list-cache-max> <clean-read-ahead-on-load>false</clean-read-ahead-on-load> <unknown-pk> <key-generator-factory>UUIDKeyGeneratorFactory</key-generator-factory> <unknown-pk-class>java.lang.String</unknown-pk-class> <jdbc-type>VARCHAR</jdbc-type> <sql-type>VARCHAR(32)</sql-type> </unknown-pk> <entity-command name="default"/> <ql-compiler>org.jboss.ejb.plugins.cmp.jdbc.JDBCEJBQLCompiler</ql-compiler> </defaults>
and in the type mapping section I have
<type-mapping> <name>MS ACCESS</name> . . . <mapping> <java-type>java.lang.String</java-type> <jdbc-type>VARCHAR</jdbc-type> <sql-type>VARCHAR(255)</sql-type> </mapping> . . </type-mapping>
Additionally, my msaccess-ds.xml file is
<datasources>
<local-tx-datasource>
<jndi-name>DefaultDS</jndi-name>
<!-- format of URL is "jdbc:odbc:DSNNAME" -->
<connection-url>jdbc:odbc:EpidemiologyWebData</connection-url>
<!--
<connection-property name="SelectMethod">cursor</connection-property>
-->
<driver-class>sun.jdbc.odbc.JdbcOdbcDriver</driver-class>
<user-name></user-name>
<password></password>
</local-tx-datasource>
<!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
<metadata>
<type-mapping>MS ACCESS</type-mapping>
</metadata>
</datasources>
Upon startup I get the following error
18:31:48,640 ERROR [EntityContainer] Starting failed jboss.j2ee:jndiName=ejb/UserLocal,service=EJB
org.jboss.deployment.DeploymentException: Error while creating table complianceproject; - nested throwable: (java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Size of field 'name' is too long.)
Looking in the odbc log I see
tools.jar org.j e7c-878 EXIT SQLExecDirect with return code -1 (SQL_ERROR)
HSTMT 04F42960
UCHAR * 0x03F31410 [ -3] "CREATE TABLE complianceproject (name VARCHAR(256), deadline TIMESTAMP, instructions VARCHAR(256))\ 0"
SDWORD -3
DIAG [37000] [Microsoft][ODBC Microsoft Access Driver] Size of field 'name' is too long. (-1506)
My question is why is this happening? It appears that I have set the max to be 255. Where else could the 256 be coming from?
Thanks
Tony