Hi, Shivam
Please post your
question in the birt news group at Eclipse or at http://www.birt-exchange.org/forum/
.
This mailing list
is for discussion of development of the BIRT project.
Br,
wenfeng
From: birt-report-designer-dev-bounces@xxxxxxxxxxx
[mailto:birt-report-designer-dev-bounces@xxxxxxxxxxx] On Behalf Of Shivam
Sent: Wednesday, June 24, 2009 6:26 AM
To: birt-report-designer-dev@xxxxxxxxxxx
Subject: [birt-report-designer-dev] Reg. Two Sql connection for
scripteddata source and sql connection termination
Hi,
I am using BIRT 2.2.0 .
I have created a class that access mysql database and returns some data.
This class I am using for a scripted data source.
Now the problem that I am facing are :
1. For every creation of report , two database connection are made to the
database. I am not able to figure out why ?
2. After the report is rendered , those connection do not terminate and
continue indefinitely and are closed only after I close eclipse. Thus connections
keep on gathering and after sometime databases server crashes.
I guess their is no error with the class file.
Evern so it is as follows
package BIRT;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
public class Mysqlclass {
public List<String[]> data() {
Connection con = null;
ArrayList <String[]> result = new
ArrayList <String[]>();
try {
Class.forName("com.mysql.jdbc.Driver");
String url =
"">
// Get a connection to
the database for a
// user named auser
with the password
// drowssap, which is
password spelled
// backwards.
con =
DriverManager.getConnection(url, "root","password");
Statement st =
con.createStatement();
ResultSet rs =
st.executeQuery("select UserLogin,StatType from table");
while(rs.next())
{
String[] result1 = {"",""};
result1[0]= rs.getString("UserLogin");
result1[1]=rs.getString("StatType");
result.add(result1);
}
} catch (Exception e) {
e.printStackTrace();
System.out.println("Exception: " + e.getMessage());
} finally {
try {
if
(con != null)
con.close();
} catch (SQLException
e) {
System.out.println("Error with closing the collection");
}
}
return result;
}
}
Any help will be greatly appreciated.
Regards,
Shivam Agarwal