Tuesday, March 11, 2014

MySQL DataSource in WebLogic Server

Zemian's Blog


How to create MySQL DataSource in WebLogic Server

One cool thing about using an application server is that it allows you to create DataSource outside of your application and it can manage it along with connections pool and transaction manager etc. With WebLogic Server, it comes with quite a few built in JDBC drivers such as Oracle Database and MySQL etc ready for your use. Here I will show you how to create a MySQL DataSource.

1. Login into http://localhost:7001/console
2. On the left menu click Services > Data Sources
3. On the right, click "New" button
4. Enter Name: mysql_ds ; You may optionally give it an JNDI Name: jdbc/mysql_ds; And then select Database Type: MySQL
5. Click "Next" button and then accept default with another two "Next" buttons.
6. Now enter Database Name: test; Host Name: localhost; Database User Name: root; and then the password.
7. Click "Next" and you may optionally test your connection here.
8. Click "Next" and you MUST select an sever as target! 
9. Click "Finish"


Now you have a DataSource ready to be used by your application on this server. You may access this by either JNDI lookupor JPA configuration with entity manager injection.

TIPS: If you do not pick a server Target in step 8, then your applicatoin will NOT able to access this Data Source! So ensure you have done this step as it's the easy step to miss.

Thursday, April 16, 2009

Oracle JDeveloper 11g with MySQL

How To Use ADF Business Components in Oracle JDeveloper 11g with MySQL:

Configure JDeveloper to work with MySQL Connector/J

  • Download MySQL Connector/J 3.0.11 unzip it and copy the JDBC driver JAR file to a known location, such as /jdev/lib (mine is C:\bea\jdeveloper\jdev\lib)
  • From the Tools menu, select Default Project Properties.
  • In the tree view, select Libraries and Classpath.
  • In the right pane, select Add Libary. The 'Add Library' dialog will be displayed.
  • select New. The 'Create Library' dialog will be displayed.
  • Name the library MySQL JDBC.
  • Set the location to User.
  • Click on Class Path.
  • Click Add Entry. The 'Select Path Entry' dialog is displayed.

  • Navigate to the JAR file for the MySQL Connect/J JDBC driver (it should be called something like C:\bea\jdeveloper\jdev\lib\mysql-connector-java--bin.jar).
  • Click on the jar file and click Select.
  • Click OK.
  • Click OK.
  • The library will be defined, and it will be in the Selected Libraries list. You probably don't want that library to be defined in all your projects, so shuttle it over to the Available Libraries list.
  • Click OK.
Now you can use that library in any of your projects.


Tuesday, March 24, 2009

JSF Renderers

Each of the JSF tag gives rise to an associated component.
A renderer is a type of class that is responsible for encoding and decoding components.

Encoding:

For example: Suppose we have used h:inputText tag . So the renderer of the component associated with this tag produces the following output:

<input type=”text” name=”ID” value=”current_value”/>


Additional User-Interface Component Libraries

Because of the richness and flexibility of the JSF API, many Java developers are beginning to create new JSF Component libraries and implementations. Oracle's ADF Faces is a fully compliant JSF component library which offers a broad set of enhanced UI Components for JSF application development. These include multiple renderers per client type, advanced tables, color and date pickers along with a host of general components such as menus, command buttons, shuttle choosers and progress meters.

MyFaces is an example of a new JSF UI Component Library being offered as an Open Source project through Apache. Myfaces also serves as an enhancement to the JSF base UI components in that they also have more extensive UI capabilities such as integrated Tiles support, Javascript enabled menus and Tree controls.


Writing JSF components can be a difficult task, but using them is as simple as a call to a tag. And that is exactly the strength and coolness of Faces.

Friday, March 20, 2009

Little about Java Server Faces (JSF)

Why JSF?

Let's first understand the reasons that initiated the JSF project and why JSF is so hot these days. There are reasons for development of new framework in-spite of many already existing technologies like JSP, Servlets, Struts etc... Using these technologies programmers directly work with HTTP request and response objects and manipulates the data. For example if user submits the registration form then programmer writes the code to get the values of each element in the form into a variable for further processing.

JSF was developed by Java Community Process(JCP). This is a community of web application experts. Java Server Faces or JSF for short, is the standard framework to simplify the process of developing web application in java.

So main purpose of developing JSF was to create a collection of APIs for the UI components with the capacity to manage their states, handle events and validation.
JSF is based on well established Model-View-Controller (MVC) design pattern.



Java Server Pages
In order to move away from this programmatic view of web page development,
the next step in the evolution brought us to Java Server Pages (JSP). These were
“special” tags that could be embedded into a web page. These tags were used by
the JSP container to generate servlets, that in turn generated the markup. So, you
had the concepts of developers who could develop JSP tags, and possibly a
different set of developers who could use the tags via JSTL (JSP Standard Tag
Libraries).
However, this still represented a “tag” based view of UI development and still
required the UI developer to understand the intricacies of HTTP protocols and to
manage state.
Thus, JSF finally brings the development of web UIs to the stage where developers
can work with visual controls that support an event model and allow visual editing
through IDEs such as Oracle JDeveloper।

JSF Core Tags Library and JSF Html Tags Library
Even a very simple page uses tags from both libraries.



<%@ taglib uri=”http://java.sun.com/jsf/core “ prefix=”f” %>

<%@ taglib uri=”http://java.sun.com/jsf/html “ prefix=”h” %>

<f:view>

<h:form>

……………

……………

</h:form>

</f:view>



All JSF Html Tags :
column creates column in a dataTable
commandButton creates button
commandLink creates link that acts like a pushbutton
dataTable creates a table control
form creates a form
graphicImage displays an image
inputHidden creates hidden field
inputSecret creates input control for password
inputText creates text input control (single line)
inputTextarea creates text input control (multiline)
message displays the most recent message for a component
messages displays all messages
outputFormat creates outputText, but formats compound messages
outputLabel creates label
outputLink creates anchor
outputText creates single line text output
panelGrid creates html table with specified number of columns
panelGroup used to group other components where the specification requires one child element
selectBooleanCheckbox creates checkbox
selectManyCheckbox creates set of checkboxes
selectManyListbox creates multiselect listbox
selectManyMenu creates multiselect menu
selectOneListbox creates single select listbox
selectOneMenu creates single select menu
selectOneRadio creates set of radio buttons