NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Connect to data source when making web report with Java reporting tool

 
Post new topic   Reply to topic    NetBeans Forums -> Java EE Users
View previous topic :: View next topic  
Author Message
becklery



Joined: 18 Apr 2009
Posts: 58

PostPosted: Tue May 12, 2009 3:04 pm    Post subject: Connect to data source when making web report with Java reporting tool Reply with quote

Background
When users are making web report, they always have to connect to data source. As users' data requirements are differ in thousand ways, so users often need to define data source by themselves. Sometimes, this may be very complex.

Solution
As a professional Java web-based reporting tool, RAQ Report givesout two methods to solve this problem.

1. Connect to data source with the API of RAQ Report. And the program is as follows:
context.setDefDataSourceName("demo");
context.setConnection("demo",con);
DataSourceConfig dsoc = new DataSourceConfig(2,
true, "GBK", "GBK", false);
context.setDataSourceConfig("demo", dsoc);

2. Connect to data source with jdbc. And the program is as follows:
public java.sql.Connection getConnection() throws Exception {
Connection conn=null;
try{
Class.forName("org.hsqldb.jdbcDriver");
}catch(ClassNotFoundException cne){
cne.printStackTrace();
}
try{
conn= DriverManager.getConnection("jdbc:hsqldb:hsql://localhost:9001/runqianDB","sa","");
}catch(SQLException e){
e.printStackTrace();
}
return conn;
}
When develop web reporting project, users can connect to data source easily with these two methods provided by RAQ Report. Accoding to real business, users can choose a better one.

This post is from freezea's blog. You are welcomed cc it anywhere, and please indicate the source.

If you would like to read more articles about reporting tool, you can refer to his blog.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> Java EE Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo