[JNDI/Naming/Network] - Re: Multiable JNDI names to one XA datasource
by webmarck
Found the answer myself :-)
| <datasources>
| <xa-datasource>
| <jndi-name>jdbc/aConnection</jndi-name>
| <track-connection-by-tx/>
| <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
| <xa-datasource-property name="ServerName">localhost</xa-datasource-property>
| <xa-datasource-property name="PortNumber">5432</xa-datasource-property>
| <xa-datasource-property name="DatabaseName">someDB</xa-datasource-property>
| <xa-datasource-property name="User">someUser</xa-datasource-property>
| <xa-datasource-property name="Password">somePassword</xa-datasource-property>
| </xa-datasource>
| <mbean code="org.jboss.naming.NamingAlias" name="jboss.jmx:alias=aAlias">
| <attribute name="FromName">java:jdbc/aAlias</attribute>
| <attribute name="ToName">java:jdbc/aConnection</attribute>
| </mbean>
| <mbean code="org.jboss.naming.NamingAlias" name="jboss.jmx:alias=anotherAlias">
| <attribute name="FromName">java:jdbc/anotherAlias</attribute>
| <attribute name="ToName">java:jdbc/aConnection</attribute>
| </mbean>
| </datasources>
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4158184#4158184
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4158184
17 years, 10 months
[Persistence, JBoss/CMP, Hibernate, Database] - jboss apps need to save the session in 2 different databases
by gan.gary
I have a jboss apps need to save the session in 2 different databases.
Does it mean i need to do something like this:
public MyClass() throws NamingException {
| InitialContext ctx = new InitialContext();
| //TODO : use "hibernate.cfg.xml" if tester
| SessionFactory sessionFactory = (SessionFactory)
| ctx.lookup("java:/hibernate/SessionFactory");
| //SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
|
| session = sessionFactory.openSession();
| // session 2
| SessionFactory sessionFactory2 = (SessionFactory)
| ctx.lookup("java:/hibernate/SessionFactory2");
|
|
| session2 = sessionFactory2.openSession();
| }
|
| // this go to db 1
| Transaction tx = null;
| try{
| tx = session.beginTransaction();
| Vector v = new Vector(hash1.keySet());
| Collections.sort(v);
| Long nUID = null;
| Iterator it = v.iterator();
| while (it.hasNext()) {
| nUID = (Long)it.next();
| Obj1 obj1= hash1.get(nUID);
| session.save(obj1);
| }
| session.flush();
|
| // this go to db 2
| Transaction tx2 = null;
| try{
| tx2 = session2.beginTransaction();
| Vector v = new Vector(hash2.keySet());
| Collections.sort(v);
| Long nUID = null;
| Iterator it = v.iterator();
| while (it.hasNext()) {
| nUID = (Long)it.next();
| Obj1 obj1= hash1.get(nUID);
| session2.save(obj1);
| }
| session2.flush();
I have found other post quite similar http://www.jboss.com/index.html?module=bb&op=viewtopic&t=137065 with me?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4158180#4158180
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4158180
17 years, 10 months
[EJB 3.0] - Re: Transaction not active exception
by jaikiran
"green804" wrote :
| This method is running a select against the DB. It takes about .15 seconds to complete. I'm checking the the transaction timeout value with the sys admin.
|
The default transaction timeout is 5 minutes (=300 seconds) and is set in the jboss-service.xml in %JBOSS_HOME%\server\< serverName>\conf folder.
"green804" wrote :
| I do not have a transaction attribute on the moethod.
|
So, by default, the transaction attribute of that method will be REQUIRED.
"green804" wrote :
| I do not need transctions for this method. It's a select. Do you have any examples of how to set the transaction attribute? Can I do it using annotations?
|
Yes, you can set the transaction attribute on that method using annotations. If you don't need transaction on that method, you can set it as follows:
| @TransactionAttribute(TransactionAttributeType.SUPPORTS)
| public ... getUserData(...) {
See this http://docs.sun.com/app/docs/doc/819-3669/6n5sg7cm3?a=view for the available transaction attribute types and their meaning.
"green804" wrote :
| If I was to need a transaction for an update of user data, what should I set the transaction attribute to?
|
REQUIRED should work. See that link that i mentioned above. That should help you in deciding the correct transaction attribute type.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4158148#4158148
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4158148
17 years, 10 months