1. สร้าง Project ใหม่โดยเลือกที่ File-> New-> Flex Project แล้วสร้าง Application ชื่อ Hello World
2. เราจะได้ไฟล์ main.mxml เลือกเป็น code view
3. เพิ่ม code
4. กดปุ่ม run ก็จะได้ Hello world application แบบง่ายๆ ออกมา
CREATE PROCEDURE SP_THROW_MESSAGE(pInput smallint)
begin
if(pInput = 1) then
insert into tablename values('x');
else
--throw exception
SIGNAL SQLSTATE '99999' SET MESSAGE_TEXT = 'test throw exception';
end if;
end
call SP_THROW_MESSAGE(2)
CREATE PROCEDURE SP_THROW_MESSAGE(pInput smallint)
begin
declare exit handler for sqlexception
p1:begin
SIGNAL SQLSTATE '12345' SET MESSAGE_TEXT = 'TEST';
end p1;
insert into tablename values('x');
end
call SP_THROW_MESSAGE()
Server1
[trunk1]
type=peer
host=10.1.1.2
username=102
secret=102
fromuser=102
Server2
[trunk2]
type=peer
host=10.1.1.1
username=101
secret=101
fromuser=101
Server1
exten=>_9.,1,Dial(SIP/${EXTEN:3}@trunk1,30,r)
Server2
exten=>_9.,1,Dial(SIP/${EXTEN:3}@trunk2,30,r)
def index = {
def reportFile = servletContext.getResource("/report/test_text.jasper")
def reportName = "testing"
def parameters = new HashMap();
createPdfFile(generateTextReport(reportFile, parameters).toByteArray(), reportName)
return null;
}
private generateTextReport(jasperFile, parameters) {
InputStream input = jasperFile.openStream()
JRTextExporter exporter = new JRTextExporter()
ByteArrayOutputStream byteArray = new ByteArrayOutputStream()
def env = grails.util.GrailsUtil.environment
def config = new ConfigSlurper(env).parse(new File('./grails-app/conf/DataSource.groovy').toURL())
def url = config.dataSource.url
def driverName = config.dataSource.driverClassName
def username = config.dataSource.username
def password = config.dataSource.password
Class.forName(driverName)
Connection connection = DriverManager.getConnection(url, username, password)
JasperPrint jasperPrint = JasperFillManager.fillReport(input, null, connection)
jasperPrint.setLocaleCode(Locale.getDefault().getCountry())
exporter.setParameter(JRTextExporterParameter.CHARACTER_ENCODING, "UTF-8");
exporter.setParameter(JRTextExporterParameter.PAGE_WIDTH, 76);
exporter.setParameter(JRTextExporterParameter.PAGE_HEIGHT, 80);
exporter.setParameter(JRTextExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRTextExporterParameter.OUTPUT_STREAM, byteArray);
exporter.exportReport()
return byteArray
}
private createPdfFile(contentBinary, fileName) {
response.setHeader("Content-disposition", "attachment; filename=" + fileName + ".txt");
response.contentType = "text/plain"
response.outputStream << contentBinary
}
HashMap fontMap = new HashMap();
FontKey key = new FontKey("Angsana New", false, false);
PdfFont font = new PdfFont("ANGSA.TTF", BaseFont.IDENTITY_H, true);
fontMap.put(key, font);
exporter.setParameter(JRExporterParameter.FONT_MAP, fontMap);
exporter.exportReport()
static mapping = {
table 'book_store'
}
<tiles-definitions>
<definition name=".template" template="/WEB-INF/tiles/template_main2.jsp">
<put-attribute name="title" value="" />
<put-attribute name="script" value="" />
<put-attribute name="action" value="" />
<put-attribute name="content" value="" />
</definition>
<definition name="hello" extends=".template">
<put-attribute name="title" value="Home Pages" />
<put-attribute name="script" value="/WEB-INF/js/*.js" />
<put-attribute name="action" value="hello" />
<put-attribute name="content" value="/WEB-INF/jsp/hello.jsp" />
</definition>
<tiles-definitions>
<html>
<head>
<title>Spring App : <tiles:getAsString name="title" /></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
</head>
<body>
<h1> This from template</h1>
<tiles:insertAttribute name="content"/>
</body>
</html>