In .jrxml file, it is created using "groovy" language. It occurs error while converting .jrxml file to .jasper file.
Following is shown a error message occurs while converting to .jasper file.
Exception in thread "main" java.lang.NoClassDefFoundError: org/codehaus/groovy/control/CompilationFailedException
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at net.sf.jasperreports.engine.util.JRClassLoader.loadClassForRealName(JRClassLoader.java:157)
at net.sf.jasperreports.engine.util.JRClassLoader.loadClassForName(JRClassLoader.java:115)
at net.sf.jasperreports.engine.JasperCompileManager.getCompiler(JasperCompileManager.java:511)
at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:215)
at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:148)
at src.JasperCheck.main(JasperCheck.java:31)Caused by: java.lang.ClassNotFoundException: org.codehaus.groovy.control.CompilationFailedException
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) ... 8 moreJava Result: 1
Solution to above error is to change .jrxml language type from "groovy" to "java"
Monday, July 30, 2012
Friday, July 27, 2012
Informix Database LOCK Transaction for UPDATE
In some cases, we have to lock records for update. Below code segments can be used for locking table and update desired record in informix database server.
- statement.executeUpdate("Begin Work");
- statement.executeUpdate("set transaction isolation level serializable");
Above code must be used be before the SELECT statement execution which must be UPDATE.
- String sql_1="select * from table where name='sujith' FOR UPDATE";
Execute the sql and proceed with the business logic. When you want to UPDATE the table do the following.
- String sql_2=update table set name="delp" where name="sujith";
Execute the UPDATE statement, like above statement.
Then use below command for commiting transaction to database.
- statement.executeUpdate("commit");
Tuesday, July 24, 2012
Print When Expression in Jasper Report
In some cases, we need to filter data values while printing in the report.
There is a special feature in iReport for this called as "Print When Expression".
In this expression, you have to insert Boolean function to the iReport.
For example :-
new Boolean($P!(var_name).toString.equals("5"))
Suppose the parameter variable is "var_name". If the value of the "$P!(var_name)" is equal to "5", it will print the value. Else, it will print null/blank value.
Jasper report Pass SQL to report as parameter
In jasper report, parameters can be categorized into a few data types. According to the data type, parameter value is attached single quote.
For example, parameter data type is String, it is attached single quote (') between parameter value.
In some cases, we have to pass whole SQL to jasper report to generate report.
If we sent the SQL as a parameter it will return error, because of adding single quotes to parameter.
Solution is to have a ! sign before the parameter value as shown is below.
If the parameter value is "Query", it can be avoided adding single quote to parameter like below.
$P!{Query}
NOTE :- SQL can be a normal SQL statement
For example, parameter data type is String, it is attached single quote (') between parameter value.
In some cases, we have to pass whole SQL to jasper report to generate report.
If we sent the SQL as a parameter it will return error, because of adding single quotes to parameter.
Solution is to have a ! sign before the parameter value as shown is below.
If the parameter value is "Query", it can be avoided adding single quote to parameter like below.
$P!{Query}
NOTE :- SQL can be a normal SQL statement
Friday, June 1, 2012
Oracle data format
When inserting data into Oracle Database it is needed to format data. Here, it is shown, how is TIMESTAMP is used in Oracle.
id_ref_no_seq.nextval call the sequence created before. It will increase ref_no value by one and insert back into database.
insert into TABLE_NAME(ref_no,start_time) values(id_ref_no_seq.nextval,TO_TIMESTAMP('2012-06-01 11:41:20.061', 'YYYY-MM-DD HH.MI.SSXFF'))
id_ref_no_seq.nextval call the sequence created before. It will increase ref_no value by one and insert back into database.
insert into TABLE_NAME(ref_no,start_time) values(id_ref_no_seq.nextval,TO_TIMESTAMP('2012-06-01 11:41:20.061', 'YYYY-MM-DD HH.MI.SSXFF'))
Wednesday, May 30, 2012
Create SEQUENCE in Oracle
In Oracle DB, there is no AUTO_INCREMENT field like MySQL. Oracle has SEQUENCE instead of this. Below command can be used to create SEQUENCE in Oracle.
CREATE SEQUENCE id_your_seq MINVALUE 1 START WITH 1 INCREMENT BY 1 NOCACHE;
CREATE SEQUENCE id_your_seq MINVALUE 1 START WITH 1 INCREMENT BY 1 NOCACHE;
Monday, April 2, 2012
Create HTTPS Web Service Client
HTTPS web services uses certificate authentication. So, web service clients must be created with SSL.
In netbeans, you can create HTTPS web service client. Follow the steps.
1) Create Java project in Netbeans
2) Copy certificate into project root directory
3) Use Netbeans Web Service Client wizard to create client
This will create web service clients successfully. But, when calling service, it is again needed to create SSL session with service.
Before calling service, certificate needs to be stored in java key store.
Refer article on seguide :- http://seguide.blogspot.com/2009/12/use-keytool-to-generate-keys-in-java.html
Use following code before calling service methods.
System.setProperty("javax.net.ssl.trustStore", "export/home/myTrustStore"); System.setProperty("javax.net.ssl.trustStorePassword", "changeit");
System.setProperty("javax.net.ssl.trustStoreType", "JKS"); System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol"); Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
URL url = new URL("https://~~~~~~~~~~~~~~~~~~~/service.asmx?wsdl");
Service service = new Service(url); service.getServiceSoap().getData();
In netbeans, you can create HTTPS web service client. Follow the steps.
1) Create Java project in Netbeans
2) Copy certificate into project root directory
3) Use Netbeans Web Service Client wizard to create client
This will create web service clients successfully. But, when calling service, it is again needed to create SSL session with service.
Before calling service, certificate needs to be stored in java key store.
Refer article on seguide :- http://seguide.blogspot.com/2009/12/use-keytool-to-generate-keys-in-java.html
Use following code before calling service methods.
System.setProperty("javax.net.ssl.trustStore", "export/home/myTrustStore"); System.setProperty("javax.net.ssl.trustStorePassword", "changeit");
System.setProperty("javax.net.ssl.trustStoreType", "JKS"); System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol"); Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
URL url = new URL("https://~~~~~~~~~~~~~~~~~~~/service.asmx?wsdl");
Service service = new Service(url); service.getServiceSoap().getData();
Subscribe to:
Posts (Atom)