#Generated by seam setup
#Tue Apr 29 17:53:10 CST 2008
hibernate.connection.password=1234
workspace.home=/Users/macbook/project
model.package=com.infinitiessoft.prj.tcps
hibernate.default_catalog=cps
driver.jar=/Users/macbook/java/lib/mysql-connector-java-3.1.12-bin.jar
action.package=com.infinitiessoft.prj.tcps
test.package=com.infinitiessoft.prj.tcps
database.type=mysql
richfaces.skin=blueSky
hibernate.default_schema.null=
database.drop=y
project.name=tcps
hibernate.connection.username=cps
hibernate.connection.driver_class=com.mysql.jdbc.Driver
hibernate.cache.provider_class=org.hibernate.cache.HashtableCacheProvider
project.type=ear
icefaces.home=
database.exists=y
jboss.home=/Users/macbook/java/jboss-4.2.2.GA
hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.connection.url=jdbc\:mysql\://localhost\:3306/cps
icefaces=n
2008年4月29日 星期二
這是用jasper2.0.4最新版的實做
1.取出datasource
List sourceList = dao.rundata();
if(sourceList.size() < sourcelist =" java.util.Collections.EMPTY_LIST;
}
2.實作一個Map物作來存放變數
Map par = new HashMap();
par.put("par1", "par1-test1");
par.put("par2", "test2");
3.取出jasper檔案
File jasperFile= new File( config.getServletContext().getRealPath("/report/price.jasper"));
4.將.jasper File轉成jasperReport
JasperReport jr = (JasperReport) net.sf.jasperreports.engine.util.JRLoader.loadObject(jasperFile);
5.將sourceList 轉成 JRDataSource
net.sf.jasperreports.engine.JRDataSource jrds = new net.sf.jasperreports.engine.JREmptyDataSource();
jrds = new net.sf.jasperreports.engine.data.JRMapCollectionDataSource(sourceList);
6.從指定的jasperReport 檔案compiled成report design loaded
net.sf.jasperreports.engine.JasperPrint jp= JasperFillManager.fillReport(jr, par,jrds);
7.Exports the generated report object received as parameter into PDF format and returns the binary content as a byte array.
byte[] bytes = net.sf.jasperreports.engine.JasperExportManager.exportReportToPdf(jp);
8.將byte array透過response輸出成PDF
.
.(略)
response.setHeader("Content-Disposition", "inline;filename=test.pdf");
response.reset();
if (bytes != null && bytes.length != 0) {
response.setContentLength(bytes.length);
ServletOutputStream os = response.getOutputStream();
os.write(bytes, 0, bytes.length);
} else {
throw new IllegalStateException("fail to create pdf file");
}
response.flushBuffer();
.(略)
.
List sourceList = dao.rundata();
if(sourceList.size() < sourcelist =" java.util.Collections.EMPTY
}
2.實作一個Map物作來存放變數
Map
par.put("par1", "par1-test1");
par.put("par2", "test2");
3.取出jasper檔案
File jasperFile= new File( config.getServletContext()
4.將.jasper File轉成jasperReport
JasperReport jr = (JasperReport) net.sf.jasperreports.engine
5.將sourceList 轉成 JRDataSource
net.sf.jasperreports.engine
jrds = new net.sf.jasperreports.engine
6.從指定的jasperReport 檔案compiled成report design loaded
net.sf.jasperreports.engine
7.Exports the generated report object received as parameter into PDF format and returns the binary content as a byte array.
byte[] bytes = net.sf.jasperreports.engine
8.將byte array透過response輸出成PDF
.
.(略)
response.setHeader("Content
response.reset();
if (bytes != null && bytes.length != 0) {
response.setContentLength
ServletOutputStream os = response.getOutputStream();
os.write(bytes, 0, bytes.length);
} else {
throw new IllegalStateException("fail to create pdf file");
}
response.flushBuffer();
.(略)
.
2008年4月28日 星期一
mysql 變更密碼
mysql> set password for 'root'@'localhost' = password('1234');
mysql> flush privileges;或
mysql>UPDATE mysql.user SET Password = PASSWORD('
newpwd
')
->WHERE User = 'root';
mysql>FLUSH PRIVILEGES;
2008年4月25日 星期五
讀檔寫檔簡單測試
package com.file;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
public class filereaderTest {
public void filereaderTest(){
try {
FileReader fr =new FileReader("/Users/macbook/java/test.txt");
BufferedReader br= new BufferedReader (fr);
//從檔案輸入資料流入緩衝器類別物件br
String line;
while ((line =br.readLine())!=null) {
System.out.println(line);
}
System.out.println("========讀檔成功=========");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("========找不到檔案,讀檔失敗=========");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("========讀檔失敗=========");
}
}
public void filewritetest(){
BufferedWriter bw;
try {
bw = new BufferedWriter (
new FileWriter("/Users/macbook/java/test1.txt"));
//輸出資料流入緩衝器後再輸出到系統標準輸出
String s="字元輸出資料流BufferedWriter測試234!";
bw.write( s, 0, s.length( ) ); //用write方法將s輸出
bw.close();
System.out.println("========寫檔成功=========");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("========寫檔失敗=========");
}
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
new filereaderTest().filewritetest();
}
}
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
public class filereaderTest {
public void filereaderTest(){
try {
FileReader fr =new FileReader("/Users/macbook/java/test.txt");
BufferedReader br= new BufferedReader (fr);
//從檔案輸入資料流入緩衝器類別物件br
String line;
while ((line =br.readLine())!=null) {
System.out.println(line);
}
System.out.println("========讀檔成功=========");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("========找不到檔案,讀檔失敗=========");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("========讀檔失敗=========");
}
}
public void filewritetest(){
BufferedWriter bw;
try {
bw = new BufferedWriter (
new FileWriter("/Users/macbook/java/test1.txt"));
//輸出資料流入緩衝器後再輸出到系統標準輸出
String s="字元輸出資料流BufferedWriter測試234!";
bw.write( s, 0, s.length( ) ); //用write方法將s輸出
bw.close();
System.out.println("========寫檔成功=========");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("========寫檔失敗=========");
}
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
new filereaderTest().filewritetest();
}
}
2008年4月22日 星期二
2008年4月21日 星期一
mysql常用指令(一)
1.顯示DATABASE 所有的DB
mysql> SHOW DATABASES;
+-----------------------+
| Database |
+-----------------------+
|information_schema |
| TICP |
| foodmart |
| jasperserver |
| mysql |
| report |
| sowoo |
| sugarcrm |
| test |
+-----------------------+
9 rows in set (0.00 sec)
2. 顯示該 DB 的所有table
mysql> show tables from mysql;
+---------------------------+
| Tables_in_mysql |
+---------------------------+
| columns_priv |
| db |
| func |
| help_category |
| user |
| user_info |
+---------------------------+
18 rows in set (0.00 sec)
3. 指定使用某一個DB(這邊以mysql預設的為例)
mysql> USE MYSQL;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
4. 查詢資料
mysql> SELECT USER FROM USER;
+---------------+
| USER |
+--------------+
| jasperdb |
| root |
| root |
| jasperadmin |
| jimmy |
| root |
+--------------+
6 rows in set (0.00 sec)
mysql> SHOW DATABASES;
+-----------------------+
| Database |
+-----------------------+
|information_schema |
| TICP |
| foodmart |
| jasperserver |
| mysql |
| report |
| sowoo |
| sugarcrm |
| test |
+-----------------------+
9 rows in set (0.00 sec)
2. 顯示該 DB 的所有table
mysql> show tables from mysql;
+---------------------------+
| Tables_in_mysql |
+---------------------------+
| columns_priv |
| db |
| func |
| help_category |
| user |
| user_info |
+---------------------------+
18 rows in set (0.00 sec)
3. 指定使用某一個DB(這邊以mysql預設的為例)
mysql> USE MYSQL;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
4. 查詢資料
mysql> SELECT USER FROM USER;
+---------------+
| USER |
+--------------+
| jasperdb |
| root |
| root |
| jasperadmin |
| jimmy |
| root |
+--------------+
6 rows in set (0.00 sec)
在mac os上加上ant的環境變數
用vi 去.profile加上以下的二行
export ANT_HOME="/Users/macbook/java/apache-ant-1.7.0"
export PATH=$ANT_HOME/bin:$PATH
export ANT_HOME="/Users/macbook/java/apache-ant-1.7.0"
export PATH=$ANT_HOME/bin:$PATH
訂閱:
文章 (Atom)