http://download.oracle.com/otn_hosted_doc/jdeveloper/11gdemos/DataDashboards/DataDashboards.html?utm_source=dlvr.it&utm_medium=twitter
Tuesday, 20 December 2011
ORACLE ADF 11G RUNTIME DEMO
ORACLE ADF 11G RUNTIME DEMO
http://jdevadf.oracle.com/adf-richclient-demo/faces/index.jspx
http://jdevadf.oracle.com/adf-richclient-demo/faces/index.jspx
Saturday, 17 December 2011
Upload and Display Image from Database Blob Column in Oracle ADF Jdeveloper 11g R2
1- MAKE NEW SERVLET
COPY TEXT FROM BELOW TO NEW SERVLET.
DEFINE IMAGE SOURCE WITH SERVLET NAME AND PARAMETER VALUE.
DISPLAY MAGE SERVLET CODING
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.sql.Blob;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.sql.DataSource;
public class Servlet1 extends HttpServlet {
private static final String CONTENT_TYPE = "image/gif; charset=utf-8";
public void init(ServletConfig config) throws ServletException {
super.init(config);
}
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException,
IOException {
response.setContentType(CONTENT_TYPE);
String imageId = request.getParameter("id");
OutputStream os = response.getOutputStream();
Connection conn = null;
try {
Context ctx = new InitialContext();
conn = getOracleConnection();
PreparedStatement statement =
conn.prepareStatement("SELECT employee_id,pic " +
"FROM employees " +
"WHERE employee_id = ?");
statement.setInt(1, new Integer(imageId));
ResultSet rs = statement.executeQuery();
if (rs.next()) {
Blob blob = rs.getBlob("PIC");
BufferedInputStream in = new BufferedInputStream(blob.getBinaryStream());
int b;
byte[] buffer = new byte[10240];
while ((b = in.read(buffer, 0, 10240)) != -1) {
os.write(buffer, 0, b);
}
os.close();
}
} catch (Exception e) {
System.out.println(e);
} finally {
try {
if (conn != null) {
conn.close();
}
} catch (SQLException sqle) {
System.out.println("SQLException error");
}
}
}
public static Connection getOracleConnection() throws Exception {
String driver = "oracle.jdbc.driver.OracleDriver";
String url = "jdbc:oracle:thin:@localhost:1521:orcl";
String username = "hr";
String password = "hr";
Class.forName(driver); // load Oracle driver
Connection conn = DriverManager.getConnection(url, username, password);
return conn;
}
}
UPLOAD IMAGE CODING
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.sql.SQLException;
import oracle.adf.model.BindingContext;
import oracle.adf.model.binding.DCBindingContainer;
import oracle.adf.model.binding.DCIteratorBinding;
import oracle.binding.BindingContainer;
import oracle.jbo.Row;
import oracle.jbo.domain.BlobDomain;
import org.apache.myfaces.trinidad.model.UploadedFile;
public class UploadBean {
public UploadBean() {
super();
}
private UploadedFile _file;
public UploadedFile getFile() {
return _file;
}
public void setFile(UploadedFile file) {
_file = file;
}
public String uploadImage() {
UploadedFile myfile = (UploadedFile)this.getFile();
BindingContext bindingctx = BindingContext.getCurrent();
BindingContainer bindings = bindingctx.getCurrentBindingsEntry();
DCBindingContainer bindingsImpl = (DCBindingContainer)bindings;
DCIteratorBinding iter = bindingsImpl.findIteratorBinding("ABCView1Iterator");
Row row = iter.getCurrentRow();
row.setAttribute("Pic", createBlobDomain(myfile));
return null;
}
private BlobDomain createBlobDomain(UploadedFile file) {
InputStream in = null;
BlobDomain blobDomain = null;
OutputStream out = null;
try {
in = file.getInputStream();
blobDomain = new BlobDomain();
out = blobDomain.getBinaryOutputStream();
byte[] buffer = new byte[8192];
int bytesRead = 0;
while ((bytesRead = in.read(buffer, 0, 8192)) != -1) {
out.write(buffer, 0, bytesRead);
}
in.close();
} catch (IOException e) {
e.printStackTrace();
} catch (SQLException e) {
e.fillInStackTrace();
}
return blobDomain;
}
}
Friday, 16 December 2011
Some Usefull Sql Queries
- To separate number from text (SELECT ltrim('6372Tech', '0123456789') FROM DUAL; )
- Translate character to 'x' (SELECT translate('1tech23', '0123456789', 'xxxxxxxxx') FROM DUAL;)
- null if value = 10 (SELECT NULLIF(10,10) FROM DUAL;)
- select supplier_id,
CASE
WHEN supplier_name = 'IBM' and supplier_type = 'Hardware' THEN 'North office'
WHEN supplier_name = 'IBM' and supplier_type = 'Software' THEN 'South office'
END
from suppliers; - Find date of next month 1st TUESDAY (select next_day(trunc(add_months(sysdate,1),'MM'),'TUESDAY') from dual)
SELECT
2 month, SUM(amount) AS month_amount,
3 SUM(SUM(amount)) OVER
4 (ORDER BY month ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
5 AS cumulative_amount
6 FROM all_sales
7 GROUP BY month
8 ORDER BY month;
MONTH MONTH_AMOUNT CUMULATIVE_AMOUNT
---------- ------------ -----------------
1 58704.52 58704.52
2 28289.3 86993.82
3 20167.83 107161.65
4 50082.9 157244.55
5 17212.66 174457.21
6 31128.92 205586.13
7 78299.47 283885.6
8 42869.64 326755.24
9 35299.22 362054.46
10 43028.38 405082.84
11 26053.46 431136.3
12 20067.28 451203.58
12 rows selected.
Monday, 12 December 2011
Oracle Weblogic 11g Domain Creation and Jdeveloper ADF 11g Deployment
Oracle Weblogic 11g Domain Creation and Jdeveloper ADF 11g Deployment
Subscribe to:
Posts (Atom)