我是用itext开源库生成pdf的
以下是报错
ORA-29532:Java call terminated by uncaught Java exception:
javax.xml.parsers.FactoryConfigurationError:java.security.AccessControlException:the Permission (java.lang.RuntimePermission getClassLoader) has not been granted to DBOWN.The PL/SQL to grant this is dbms_java.grant_permission('DBOWN','SYS:java.lang.Rumtime.Permission','getClassLoader','')
ORA-06512:at "DBOWN.PDFTEST",line 0
ORA-06512:at line 8以下是测试脚本:
-- Created on 2007-7-11 by ADMIN
declare
-- Local variables here
i integer;
begindbms_java.grant_permission('DBOWN', 'SYS:java.lang.RuntimePermission', 'getClassLoader', null );
pdftest;
end;
以下是报错
ORA-29532:Java call terminated by uncaught Java exception:
javax.xml.parsers.FactoryConfigurationError:java.security.AccessControlException:the Permission (java.lang.RuntimePermission getClassLoader) has not been granted to DBOWN.The PL/SQL to grant this is dbms_java.grant_permission('DBOWN','SYS:java.lang.Rumtime.Permission','getClassLoader','')
ORA-06512:at "DBOWN.PDFTEST",line 0
ORA-06512:at line 8以下是测试脚本:
-- Created on 2007-7-11 by ADMIN
declare
-- Local variables here
i integer;
begindbms_java.grant_permission('DBOWN', 'SYS:java.lang.RuntimePermission', 'getClassLoader', null );
pdftest;
end;
exec dbms_java.grant_permission('用户名','java.lang.RuntimePermission','*','writeFileDescriptor' );
create or replace and compile java source named pdf as
import com.lowagie.text.BadElementException;
import com.lowagie.text.Cell;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.PageSize;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfWriter;
import java.io.FileOutputStream;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
import com.lowagie.text.SimpleCell;
import com.lowagie.text.SimpleTable;
import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.InputSource;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.StringReader;
import com.lowagie.text.Table;
import java.lang.StringBuffer;public class pdf extends DefaultHandler{
protected Table table;
protected SimpleTable table2;
protected SimpleCell currentRow;
protected int Cellindex;
protected String horb;
protected String status;
protected StringBuffer buffer;
protected String h_col[]=new String[]
{
"PONO",
"POCREATEDT",
"POSENTDT",
"POACKDT",
"POREVNO",
"POREVDT",
"ENDBUYCTTPER",
"ENDBUYCTTPERTEL",
"ENDBUYCTTPERFAX",
"ENDBUYCTTPEREMAIL",
"ENDBUYCOMADDR",
"FTY",
"FTYADDR",
"FTYCTTPER",
"FTYCTTPEREMAIL",
"DELTERM",
"PYTTERM",
"CURR",
"TTLORDVAL",
"DELADDR",
"DELDEST",
"REMARK",
"INVADDR",
"ENDBUYER",
"DIV"
};
protected int h_col_x[]=new int[]{1,1,1,1,3,3,3,3,3,5,5,5,5,5,7,7,7,7,7,9,9,9,9,9,1};
protected int h_col_y[]=new int[]{2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1};
private SimpleCell getCell(String s,float width){
SimpleCell cell=new SimpleCell(SimpleCell.CELL);
Paragraph p = new Paragraph(s);
cell.add(p);
cell.setWidthpercentage(width);
cell.setBorder(SimpleCell.BOX);
return cell;
}
private void addHeader(){
if ("h".equals(horb)){
try{
//table.addCell(new Cell("CUSTID"),1,1);
table.setWidth(100);
table.addCell(new Cell("DIV"),1,0);
table.addCell(new Cell("PONO"),2,0);
table.addCell(new Cell("POCREATEDT"),3,0);
table.addCell(new Cell("POSENTDT"),4,0);
table.addCell(new Cell("POACKDT"),5,0);
table.addCell(new Cell("POREVNO"),1,2);
table.addCell(new Cell("POREVDT"),2,2);
table.addCell(new Cell("ENDBUYCTTPER"),3,2);
table.addCell(new Cell("ENDBUYCTTPERTEL"),4,2);
table.addCell(new Cell("ENDBUYCTTPERFAX"),5,2);
table.addCell(new Cell("ENDBUYCTTPEREMAIL"),1,4);
table.addCell(new Cell("ENDBUYCOMADDR"),2,4);
table.addCell(new Cell("FTY"),3,4);
table.addCell(new Cell("FTYADDR"),4,4);
table.addCell(new Cell("FTYCTTPER"),5,4);
table.addCell(new Cell("FTYCTTPEREMAIL"),1,6);
table.addCell(new Cell("DELTERM"),2,6);
table.addCell(new Cell("PYTTERM"),3,6);
table.addCell(new Cell("CURR"),4,6);
table.addCell(new Cell("TTLORDVAL"),5,6);
table.addCell(new Cell("DELADDR"),1,8);
table.addCell(new Cell("DELDEST"),2,8);
table.addCell(new Cell("REMARK"),3,8);
table.addCell(new Cell("INVADDR"),4,8);
table.addCell(new Cell("ENDBUYER"),5,8);
}
catch(BadElementException e){
e.printStackTrace();
}
}
else{
SimpleCell headerRow = new SimpleCell(SimpleCell.ROW);
headerRow.add(getCell("AUTOID", 35));
headerRow.add(getCell("CUSTID", 35));
headerRow.add(getCell("PONO", 35));
headerRow.add(getCell("SHIPMODE", 50));
headerRow.add(getCell("SHIPDT", 35));
headerRow.add(getCell("STYL", 35));
headerRow.add(getCell("STYLDESC", 50));
headerRow.add(getCell("LINENO", 35));
headerRow.add(getCell("COLCODE", 50));
headerRow.add(getCell("COLDESC", 50));
headerRow.add(getCell("DIM", 35));
headerRow.add(getCell("SZ", 35));
headerRow.add(getCell("UNITPRC",50));
headerRow.add(getCell("ORDQTY",50));
headerRow.add(getCell("TTLLINEQTY",70));
headerRow.add(getCell("TTLLINEVAL",70));
headerRow.add(getCell("UOM",35));
headerRow.add(getCell("PPP",35));
table2.add(headerRow);
}
}
private Table gettable() {
return table;
}
private SimpleTable gettable2() {
return table2;
}
}
public void startElement(String uri, String localName, String qName,
Attributes attributes) throws SAXException{
if ("h".equals(horb)){
if ("ROWSET".equals(qName)){
addHeader();
}
}
else{
if ("ROWSET".equals(qName)){
addHeader();
}
if ("ROW".equals(qName)){
currentRow=new SimpleCell(SimpleCell.ROW);
Cellindex=0;
}
}
buffer = new StringBuffer();
}
throws SAXException {
if ("h".equals(horb)){
int i=0;
for(i=0;i<h_col.length && !h_col[i].equals(qName) ;i++);
//System.out.println(i);
if(i<h_col.length){
try{
table.addCell(new Cell(buffer.toString()),h_col_y[i],h_col_x[i]);
}
catch(BadElementException e){
e.printStackTrace();
}
}
}
else{
if("AUTOID".equals(qName)){
currentRow.add(getCell(buffer.toString().trim(),35));
Cellindex=1;
}
if("CUSTID".equals(qName)){
int tempi;
for(tempi=Cellindex+1;tempi<2;tempi++){
currentRow.add(getCell("",35));
}
currentRow.add(getCell(buffer.toString().trim(),35));
Cellindex=2;
}
if("PONO".equals(qName)){
int tempi;
for(tempi=Cellindex+1;tempi<3;tempi++){
currentRow.add(getCell("",35));
}
currentRow.add(getCell(buffer.toString().trim(),35));
Cellindex=3;
}
if("SHIPMODE".equals(qName)){
int tempi;
for(tempi=Cellindex+1;tempi<4;tempi++){
currentRow.add(getCell("",35));
}
currentRow.add(getCell(buffer.toString().trim(),35));
Cellindex=4;
}
if("SHIPDT".equals(qName)){
int tempi;
for(tempi=Cellindex+1;tempi<5;tempi++){
currentRow.add(getCell("",35));
}
currentRow.add(getCell(buffer.toString().trim(),35));
Cellindex=5;
}
if("STYL".equals(qName)){
int tempi;
for(tempi=Cellindex+1;tempi<6;tempi++){
currentRow.add(getCell("",35));
}
currentRow.add(getCell(buffer.toString().trim(),35));
Cellindex=6;
}
if("STYLDESC".equals(qName)){
int tempi;
for(tempi=Cellindex+1;tempi<7;tempi++){
currentRow.add(getCell("",35));
}
currentRow.add(getCell(buffer.toString().trim(),35));
Cellindex=7;
}
if("LINENO".equals(qName)){
int tempi;
for(tempi=Cellindex+1;tempi<8;tempi++){
currentRow.add(getCell("",35));
}
currentRow.add(getCell(buffer.toString().trim(),35));
Cellindex=8;
}
if("COLCODE".equals(qName)){
int tempi;
for(tempi=Cellindex+1;tempi<9;tempi++){
currentRow.add(getCell("",35));
}
currentRow.add(getCell(buffer.toString().trim(),35));
Cellindex=9;
}
if("COLDESC".equals(qName)){
int tempi;
for(tempi=Cellindex+1;tempi<10;tempi++){
currentRow.add(getCell("",35));
}
currentRow.add(getCell(buffer.toString().trim(),35));
Cellindex=10;
}
if("DIM".equals(qName)){
int tempi;
for(tempi=Cellindex+1;tempi<11;tempi++){
currentRow.add(getCell("",35));
}
currentRow.add(getCell(buffer.toString().trim(),35));
Cellindex=11;
}
if("SZ".equals(qName)){
int tempi;
for(tempi=Cellindex+1;tempi<12;tempi++){
currentRow.add(getCell("",35));
}
currentRow.add(getCell(buffer.toString().trim(),35));
Cellindex=12;
}
if("UNITPRC".equals(qName)){
int tempi;
for(tempi=Cellindex+1;tempi<13;tempi++){
currentRow.add(getCell("",35));
}
currentRow.add(getCell(buffer.toString().trim(),35));
Cellindex=13;
}
if("ORDQTY".equals(qName)){
int tempi;
for(tempi=Cellindex+1;tempi<14;tempi++){
currentRow.add(getCell("",35));
}
currentRow.add(getCell(buffer.toString().trim(),35));
Cellindex=14;
}
if("TTLLINEQTY".equals(qName)){
int tempi;
for(tempi=Cellindex+1;tempi<15;tempi++){
currentRow.add(getCell("",35));
exec dbms_java.grant_permission('DBOWN','SYS:java.io.FilePermission','<<ALL FILE>>','read,write,execute,delete');
exec dbms_java.grant_permission('DBOWN','java.lang.RuntimePermission','*','writeFileDescriptor' );
exec dbms_java.grant_permission('DBOWN','java.lang.RuntimePermission','*','getClassLoader' );