geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lin Sun" <linsun....@gmail.com>
Subject RE: Tomcat MySQL XA support
Date Fri, 10 Feb 2006 20:14:30 GMT
I have a simple jsp script that can lookup a server-wide datasource.   In
the jsp, I don't have to specify the driver or make the connection. I only
need to perform the lookup (the following code in a try/catch block).  The
Tranql resource adapter will take the configuration from the database
deployment plan and create the database connection pool.   And your
application is portable between different databases with minor changes in
the database deployment plan and the appropriate resource adapters.

Context initContext = new InitialContext();
Context envContext  = (Context)initContext.lookup("java:/comp/env");
DataSource ds = (DataSource)envContext.lookup("jdbc/DataSource");

Hope this helps!
Thanks, 
 
Lin


On Feb 9, 2006, at 5:36 AM, Jack Wang wrote:

>
> Does MySQL5.0.18 suport XA in Tomcat 5.5 ? I do a XA test in tomcat  
> with only a jsp file and
> necessary jars. The jsp is as:
>
> ---------------------------------------------
> <%
> Context ctx = new InitialContext();
> com.mysql.jdbc.jdbc2.optional.MysqlXADataSource xads = new
> com.mysql.jdbc.jdbc2.optional.MysqlXADataSource();
> xads.setServerName("localhost");
> xads.setDatabaseName("test");
> xads.setPortNumber(3306);
> XAConnection xcon = xads.getXAConnection("root","password");
> Connection con = xcon.getConnection();
>
> System.out.println("I get the correct xads and the con=" + con);
> System.out.println("Bind xads to InitialContext");
>
> ctx.bind("myXADB", xads);
> MysqlXADataSource mysqlXADataSource = (MysqlXADataSource)ctx.lookup 
> ("myXADB");
>
> System.out.println("Get the null MysqlXADataSource from ctx xads="  
> + mysqlXADataSource );
> %>
> ---------------------------------------------
>
>  Why mysqlXADataSource get from the InitialContext is null ?
>
>  Is this why I can not configure the XADataSource in tomcat in the  
> previous mail ?
>
>  I have waste much time in this problem, please help.
>
>  Thanks.
>
>
>
>
>
>
> Wang Jun
>
>
> 	
>
> 	
> 		
> ___________________________________________________________
> 雅虎1G免费邮箱百分百防垃圾信
> http://cn.mail.yahoo.com/


Mime
View raw message