Executing a Batch of SQL Statements in a Database

Executing a Batch of SQL Statements in a Database (Java Developers Almanac Example)

Executing a Batch of SQL Statements in a Database
With batch updating, a set of SQL statements is assembled and then sent altogether to the database for execution. Batch updating can improve performance.

This example creates a batch of insert statements. Auto-commit is disabled so that you have the choice of committing or not in the event of an exception.

請問SQL Server 2000 自訂函數裏可以用 getdate()?

SQL Server 2005可以, 但SQL Server 2000不行,可以用以下折衷的方式:

Microsoft SQL討論版 – 藍色小舖 BlueShop

新增一個View,內容如下
1 CREATE VIEW dbo.VIEW1
2 AS
3 SELECT GETDATE() AS Expr1
開新視窗(view plain) | 列印(print) | ?
CREATE VIEW dbo.VIEW1 AS SELECT GETDATE() AS Expr1
自定函數如下
1 CREATE FUNCTION dbo.NowTime ()
2 RETURNS NVARCHAR(30) AS
3 BEGIN
4 RETURN (select * from view1)
5 END
開新視窗(view plain) | 列印(print) | ?
CREATE FUNCTION dbo.NowTime () RETURNS NVARCHAR(30) AS BEGIN RETURN (select * from view1) END
使用方式
1 select convert(char(10),convert(datetime,dbo

Using JasperReports Scriptlet

別忘了compile 時要加入jar檔, 如:
F:\>javac Scriptlet.java  -classpath “C:\Program Files\jasperserver-pro-3.1\ireport\lib\jasperreports-3.1.2.jar"
並且把ireport內的classpath加入f:\

Rodrigo De Castro: Using JasperReports Scriptlet

Using JasperReports Scriptlet
Posted by Rodrigo de Castro at 6:15 AM
In a few steps:

* Create a class that extends the following class:
o net.sf.jasperreports.engine.JRDefaultScriptlet.
* Either:
o Add this class name (qualified name, actually) in the scriptletClass attribute of jasperReport element of your .jrxml file;
o Or, in case you are using iReport, declare this class in Project/Project Options menu, Scriptlet tab and “Use this scriptlet class…" option.
* After that, if you created a new method, call it using the following syntax:
o “$P{REPORT_SCRIPTLET}.methodName()".
+ In my case, I added to the group header the call to the method “priorityDescription()".

The scriptlet I created uses a field value to return a more complex description, what I am unable to do using only the variable declaration. It is also possible to override many of the methods that JRDefaultScriptlet provides, such as:

JasperReports Scriptlet Example

Rodrigo De Castro: JasperReports Scriptlet Example

JasperReports Scriptlet Example
Posted by Rodrigo de Castro at 10:12 AM Labels: english, technology
Back in October 2005, I posted some directions on how to create a Scriptlet. Since that project, I had some experience with Eclipse BIRT, but never used JasperReports again. But that post was very popular and _lots_ of people wrote comments or send me an email asking for examples. I never had the time or energy to search my old projects and find the example that motivated that post until today (finally!). This code is in production since November 2005, although it’s been a long time since I was called by the company for any maintenance.

So, below you can find an example class and some report excerpts. Refer to the previous post for more details on how they were built. I will also send both files to everyone who wrote a comment or sent me an email (if I find all emails here). In case you want to receive these files, please drop me a note that I will send whenever I have some spare time.

Database Connection Pooling with Tomcat

Database Connection Pooling with Tomcat – O’Reilly Media

Software object pooling is not a new concept. There are many scenarios where some type of object pooling technique is employed to improve application performance, concurrency, and scalability. After all, having your database code create a new Connection object on every client request is an expensive process. Moreover, with today’s demanding applications, creating new connections for data access from scratch, maintaining them, and tearing down the open connection can lead to massive load on the server.