1. 程式人生 > >潤乾報表的兩種資料來源連線jndi和jdbc

潤乾報表的兩種資料來源連線jndi和jdbc

潤乾報表的資料來源配置是在reportConfig.xml中進行設定的,支援jndi資料來源配置和jdbc直連資料來源配置兩種。在讀取配置檔案的時候,會首先讀取jndi的配置,如果沒有相關的資料來源配置則會讀取jdbc直連配置的資料來源。

1jndi資料來源配置(即:在dataSource中配置)

此配置適用於在j2ee的伺服器中配置了jndi連線池,比如tomcat伺服器配置方法如下:

1)conf\Catalina\ localhost下新建xml檔案配置了MYSQL資料庫連線池

<?xml version='1.0' encoding='GBK'?>

<Context path="/demo" docBase="demo" debug="0" privileged="true">

<Resource name="test

auth="Container" 

type="javax.sql.DataSource" 

maxActive="10" 

maxIdle="30" 

maxWait="10000" 

username="root" 

password="root

driverClassName="com.mysql.jdbc.Driver" 

url="jdbc:mysql://localhost:3306/test" 

/> 

</Context> 

個別引數說明:


2)通過reportConfig.xmljndi配置連線資料來源

<config>

      <name>dataSource</name>

      <value>test,mysql,GBK</value>

</config>

說明:關於reportConfig.xml中的jndi資料來源的配置詳細如下:

資料來源的JNDI名稱,資料庫型別[,取數時是否需要轉換編碼,資料庫字符集編碼,顯示報表時的字符集編 碼][,SQL是否需要轉碼];[重複]……

另外需要注意的:這裡的資料來源的jndi名稱要與連線池中配置的jndi資料來源名稱一致。

2jdbc直連資料來源配置

此配置適用於沒有在j2ee伺服器上配置jndi

連線池的情況。

例如mysql資料庫的詳細的配置方法如下:

<jdbc-ds-configs>

<jdbc-ds-config>

<name>test</name>

<db-type>MYSQL</db-type>

<connection-url>jdbc:mysql://localhost:3306/test</connection-url>

<driver-class>com.mysql.jdbc.Driver</driver-class>

<user-name>root</user-name>

<password>root</password>

<db-charset>GBK</db-charset>

<client-charset>GBK</client-charset>

<extend-properties></extend-properties>

</jdbc-ds-config>

</jdbc-ds-configs>