[jboss-user] [Beginners Corner] - How to change JBOSS connect to SQL Server?

Kentzhou do-not-reply at jboss.com
Thu Nov 16 09:57:47 EST 2006


I want config JBOSS to use SQL Server for BMP EJB. 

What I did as below:


Add following line in login-config.xml:

<application-policy name = "MSSQLDbRealm"> 
  
 <login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule" 
 flag = "required"> 
 <module-option name = "principal">sa</module-option> 
 <module-option name = "userName">sa</module-option> 
 <module-option name = "password">supermalibu</module-option> 
 <module-option name ="managedConnectionFactoryName"> 
 jboss.jca:service=LocalTxCM,name=EstoreDataSource
</module-option> 
 </login-module> 
  
 </application-policy> 

Add following lines in standardjbosscmp-jdbc.xml:
  
      java:/EstoreDataSource
      <!-- optional since 4.0 <datasource-mapping>Hypersonic SQL</datasource-mapping> -->

      <datasource-mapping>MS SQLSERVER2000</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>
         on-load
         <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>
      <throw-runtime-exceptions>false</throw-runtime-exceptions>
   

.......
      <type-mapping>
         MS SQLSERVER2000
         <row-locking-template>SELECT ?1 FROM ?2 with (xlock) WHERE ?3 ORDER BY ?4</row-locking-template>
         <pk-constraint-template>CONSTRAINT ?1 PRIMARY KEY (?2)</pk-constraint-template>
         <fk-constraint-template>ALTER TABLE ?1 ADD CONSTRAINT ?2 FOREIGN KEY (?3) REFERENCES ?4 (?5)</fk-constraint-template>
         <auto-increment-template>?1 IDENTITY</auto-increment-template>
         <alias-header-prefix>t</alias-header-prefix>
         <alias-header-suffix>_</alias-header-suffix>
         <alias-max-length>32</alias-max-length>
         <subquery-supported>true</subquery-supported>
         <true-mapping>1</true-mapping>
         <false-mapping>0</false-mapping>

         <function-mapping>
            <function-name>concat</function-name>
            <function-sql>(?1 + ?2)</function-sql>
         </function-mapping>
.......

But in JMX Console, I still get 
database=localDB,service=Hypersonic

why?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3986547#3986547

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3986547



More information about the jboss-user mailing list