PDA

View Full Version : Connecting to MySQL



iceman
10-12-2005, 02:51 PM
How to connect to MySQL

See http://wiki.jboss.org/wiki/Wiki.jsp?page=SetUpAMysqlDatasource

Sample mysql-ds.xml file:

&lt&;?xml version="1.0" encoding="UTF-8"?&gt&;

&lt&;!-- ===================================================================== --&gt&;
&lt&;!-- --&gt&;
&lt&;!-- JBoss Server Configuration --&gt&;
&lt&;!-- --&gt&;
&lt&;!-- ===================================================================== --&gt&;
&lt&;!-- ==================================================================== --&gt&;
&lt&;!-- Datasource config for MySQL using 2.0.11 driver --&gt&;
&lt&;!-- ==================================================================== --&gt&;


&lt&;datasources&gt&;
&lt&;local-tx-datasource&gt&;
&lt&;jndi-name&gt&;jdbc/mysqllocal&lt&;/jndi-name&gt&;
&lt&;connection-url&gt&;jdbc:mysql://localhost:3306/test&lt&;/connection-url&gt&;
&lt&;driver-class&gt&;com.mysql.jdbc.Driver&lt&;/driver-class&gt&;
&lt&;user-name&gt&;root&lt&;/user-name&gt&;
&lt&;password&gt&;&lt&;/password&gt&;
&lt&;/local-tx-datasource&gt&;
&lt&;/datasources&gt&;


Then you can create a SQLLookupRule to use this datasource (embed in an action.xml document, I used SQL_Datasource.action.xml as a template):

&lt&;component-name&gt&;org.pentaho.component.SQLLookupRule&lt&;/component-name&gt&;
&lt&;action-type&gt&;rule&lt&;/action-type&gt&;
&lt&;component-definition&gt&;
&lt&;jndi&gt&;jdbc/mysqllocal&lt&;/jndi&gt&;
&lt&;query&gt&;&lt&;![CDATA[select column1, column2 from mytesttable]]&gt&;&lt&;/query&gt&;
&lt&;/component-definition&gt&;

Post edited by: iceman, at: 10/12/2005 18:53

iceman
10-12-2005, 02:55 PM
NOTE: The XML tags posted kinda funny. You'll want to remove the &; from the samples.