<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>  JAVA</title>
	<link>http://java.assistProgramming.com</link>
	<description>Codding World &#187; JAVA</description>
	<pubDate>Sat, 23 Aug 2008 05:10:57 +0000</pubDate>
	<language>en</language>
			<item>
		<title>How to connect to an SQL database with JDBC</title>
		<link>http://java.AssistProgramming.com/how-to-connect-to-an-sql-database-with-jdbc.html</link>
		<pubDate>Fri, 20 Jun 2008 15:42:38 +0000</pubDate>
		<description><![CDATA[About JDBC
If you have java applets or other java applications and you want to connect them with standard SQL  databases like SLQ Server, Oracle, Informix, Sybase and others JDBC is the one who can help you to do that.The combination of Java&#8217;s JDBC and standard SQL makes a simple and powerful database solution. Using [...]]]></description>
			<content:encoded><![CDATA[<h2>About <acronym title='Java DataBase Connectivity'><span class='caps'>JDBC</span></acronym></h2>
<p>If you have java applets or other java applications and you want to connect them with standard <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym>  databases like SLQ Server, Oracle, Informix, Sybase and others <acronym title='Java DataBase Connectivity'><span class='caps'>JDBC</span></acronym> is the one who can help you to do that.The combination of Java&#8217;s <acronym title='Java DataBase Connectivity'><span class='caps'>JDBC</span></acronym> and standard <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> makes a simple and powerful database solution. Using <acronym title='Java DataBase Connectivity'><span class='caps'>JDBC</span></acronym> things are easy without making the complex tasks too difficult either.</p>
<p>During this article we&#8217;ll teach you haw to establish a connection between your java applications and <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> data base and we&#8217;ll do that step-by-step to understand better.</p>
<h2>Obtaining the <acronym title='Java DataBase Connectivity'><span class='caps'>JDBC</span></acronym> driver</h2>
<p>For using <acronym title='Java DataBase Connectivity'><span class='caps'>JDBC</span></acronym> you need to install the JAVA JDK. If you don&#8217;t have it already installed you  can download it(free)  at  <a rel="nofollow" href="http://java.sun.com/">Sun&#8217;s Java web site </a>.Also many IDE&#8217;s have already integrated it so you have nothing more to do just to use.Next thing you have to do is to obtain correctly the <acronym title='Java DataBase Connectivity'><span class='caps'>JDBC</span></acronym> driver.In most cases the <acronym title='Java DataBase Connectivity'><span class='caps'>JDBC</span></acronym> driver will be provided by your database vendor.Once you have this driver you have to install it.</p>
<h2>Establishing a connection is a two-step process</h2>
<p>If you installed the <acronym title='Java DataBase Connectivity'><span class='caps'>JDBC</span></acronym> driver correctly it&#8217;s very easy to establish the connection between java application and the <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> database. So for establishing that connection you have to follow the next two steps:</p>
<p>- Load the <acronym title='Java DataBase Connectivity'><span class='caps'>JDBC</span></acronym> driver.</p>
<p>- Establish the connection.</p>
<p>For undestanding better what you have to do we give you an example:</p>
<pre>
<ul><tt>//  Establish a connection to a <font color="#000099">mSQL</font> database using <acronym title='Java DataBase Connectivity'><span class='caps'>JDBC</span></acronym>.</tt><tt>import java.sql.*;</tt><tt>class JdbcTest1 {</tt><tt>    </tt><tt>    public static void main (String[] args) {</tt><tt>        try {</tt><tt>            // <strong>Step 1: Load the <acronym title='Java DataBase Connectivity'><span class='caps'>JDBC</span></acronym> driver.</strong></tt>

<tt>            Class.forName(&#8221;<font color="#000099">com.imaginary.sql.msql.MsqlDriver</font>&#8220;);</tt>

<tt>            // <strong>Step 2: Establish the connection to the database.</strong></tt>

<tt>            String url = &#8220;<font color="#000099">jdbc:msql://www.myserver.com:1114/contact_mgr</font>&#8220;;</tt>

<tt>            Connection conn = DriverManager.getConnection(url,&#8221;user1&#8243;,&#8221;password&#8221;);</tt>

<tt>        } catch (Exception e) {</tt>

<tt>            System.err.println(&#8221;Got an exception! &#8220;);</tt>

<tt>            System.err.println(e.getMessage());</tt>

<tt>        }</tt>

<tt>    }</tt>

<tt>}</tt></ul>
</pre>
<h4>The <acronym title='Java DataBase Connectivity'><span class='caps'>JDBC</span></acronym> Driver</h4>
<p>The name of the <acronym title='Java DataBase Connectivity'><span class='caps'>JDBC</span></acronym> driver will be supplied to you by your database<br />
vendor. As you can see in the <code>class.forName()</code> statements, these<br />
names will vary.</p>
<h4>The <acronym title='Uniform Resource Locator'><span class='caps'>URL</span></acronym></h4>
<p>The syntax of the DriverManager.getConection() method is: DriverManager.getConnection(String url, String username, String password);</p>
<p>Username and password are used for login to the data base.</p>
]]></content:encoded>
			</item>
		<item>
		<title>Java 2 Enterprise Edition Architecture Overview</title>
		<link>http://java.AssistProgramming.com/java-2-enterprise-edition-architecture-overview.html</link>
		<pubDate>Wed, 05 Dec 2007 15:46:17 +0000</pubDate>
		<description><![CDATA[Java 2 Enterprise Edition Architecture  Overview
Java 2 Enterprise Edition (J2EE) follows the General  Web Architecture which was described on a separate page. As discussed in the  evolution of Java, Java was initially touted as a  strong client-side contender in the mid-1990s. However in the late 1990s, it  evolved and gained [...]]]></description>
			<content:encoded><![CDATA[<h3>Java 2 Enterprise Edition Architecture  Overview</h3>
<p>Java 2 Enterprise Edition (<acronym title='Java2 Enterprise Edition'><span class='caps'>J2EE</span></acronym>) follows the General  Web Architecture which was described on a separate page. As discussed in the  evolution of Java, Java was initially touted as a  strong client-side contender in the mid-1990s. However in the late 1990s, it  evolved and gained much more acceptance as a solid middle tier tool. Over time,  Sun added components to its middle tier solution (Servlets, EJB) until in  mid-1999, Sun released its <acronym title='Java2 Enterprise Edition'><span class='caps'>J2EE</span></acronym> specification which provided a comprehensive  view of the Java middle tier solution. Java solution providers have embraced  <acronym title='Java2 Enterprise Edition'><span class='caps'>J2EE</span></acronym> which we will now explore.</p>
<p><acronym title='Java2 Enterprise Edition'><span class='caps'>J2EE</span></acronym> uses a 4-level model for web development. The browser runs on the client displaying <acronym title='HyperText Markup Language'><span class='caps'>HTML</span></acronym> and  optionally runs JavaScript. The middle tier is comprised of two layers: a  Presentation Layer and a Business Logic Layer. The data manages persistent  data in a database and, where appropriate, legacy data stores.</p>
<p><acronym title='Java2 Enterprise Edition'><span class='caps'>J2EE</span></acronym> implements the Presentation Layer with Servlets and, more recently, Java  provides the option to generate webpages with dynamic content using JavaServer  Pages (<acronym title='Java Server Pages'><span class='caps'>JSP</span></acronym>). Servlets/<acronym title='Java Server Pages'><span class='caps'>JSP</span></acronym> generate webpages with dynamic content (typically  originating from the database).  They also parse webpages submitted from the  client and pass them to Enterprise JavaBeans for handling. Servlets and JSPs run  inside a Web Server.</p>
<p><acronym title='Java2 Enterprise Edition'><span class='caps'>J2EE</span></acronym> implements the Business Logic layer with Enterprise JavaBeans (EJB).  Enterprise JavaBeans are responsible for logic like validation and calculations  as well as provided data access (e.g. database I/O) for the application.  Enterprise JavaBeans run inside an Application Sever.</p>
<p>Under <acronym title='Java2 Enterprise Edition'><span class='caps'>J2EE</span></acronym>, EJBs access a database through one of two means:</p>
<ul>
<li>using a <acronym title='Java DataBase Connectivity'><span class='caps'>JDBC</span></acronym> interface which requires a lower level of coding and/or</li>
<li>using SQLJ which provides a higher level interface to the database</li>
</ul>
<p>In addition to these components for web application, <acronym title='Java2 Enterprise Edition'><span class='caps'>J2EE</span></acronym> provides for access  by non-web clients to the business logic layer. A standalone Java application  (IIOP client) can access an EJB directly using <acronym title='Java2 Enterprise Edition'><span class='caps'>J2EE</span></acronym>&#8217;s Remote Method Invocation  (RMI) <acronym title='Application Interface'><span class='caps'>API</span></acronym>.</p>
<h3>Supporting <acronym title='Java2 Enterprise Edition'><span class='caps'>J2EE</span></acronym> APIs</h3>
<p><acronym title='Java2 Enterprise Edition'><span class='caps'>J2EE</span></acronym> provides a number of &#8220;supporting&#8221; APIs. The purpose of most of these  APIs is to enable interaction between the &#8220;main&#8221; software layers/components in  the <acronym title='Java2 Enterprise Edition'><span class='caps'>J2EE</span></acronym> architecture.</p>
<ul>
<li>Remote Method Interface (RMI)</li>
<li>Java Naming and Directory Interface (JNDI)</li>
<li>Java Message Service (JMS)</li>
<li>Java Transaction <acronym title='Application Interface'><span class='caps'>API</span></acronym> (JTA)</li>
<li>Java Database Connectivity (<acronym title='Java DataBase Connectivity'><span class='caps'>JDBC</span></acronym>) / SQLJ</li>
<li>JavaMail /JMC</li>
</ul>
<p><strong>Remote Method Interface (RMI) </strong></p>
<p>RMI is an important <acronym title='Application Interface'><span class='caps'>API</span></acronym> used for supporting distributed computing and has  been supported in core Java since version 1.1. RMI allows a Java client  application to communicate with a Java server application by invoking methods on  that remote object. With RMI, the client gets a reference to a server object and  then it can invoke methods on that object as if it were a local object within  the same virtual machine.</p>
<p>For server objects developed in other languages, you must employ other  techniques like using Java IDL with CORBA or RMI/IIOP to access the server  object.</p>
<p><strong>Java Naming and Directory Interface (JNDI)  </strong></p>
<p>JNDI allows Java programs to use name servers and directory servers to look  up objects or data by name. This important feature allows a client object to  locate a remote server object or data.</p>
<p>JNDI is a generic <acronym title='Application Interface'><span class='caps'>API</span></acronym> that can work with any name or directory servers.  Server providers have been implemented for many common protocols (e.g. NIS, LDAP  and NDS) and for CORBA object registries. Of particular interest to users of  <acronym title='Java2 Enterprise Edition'><span class='caps'>J2EE</span></acronym>, JNDI is used to locate Enterprise JavaBean (EJB) components on the  network.</p>
<p><strong>Java Message Service (JMS) </strong></p>
<p>JMS is an <acronym title='Application Interface'><span class='caps'>API</span></acronym> for using networked messaging services. Data sent in a message  is often intended as a sort of event notification (e.g. a Email-handling process  may need to be notified when a request is enqueued).  Another common use for  messaging (thus JMS) is for interfacing with &#8220;external&#8221;, third party or legacy  applications, typically via a Message Oriented Middleware product like IBM&#8217;s MQ  Series (now WebSphere MQ).   It can be complex/risky to use <acronym title='Remote Procedure Call'><span class='caps'>RPC</span></acronym>/RMI to directly  invoke remote applications while a messaging solution can provide a simpler and  more reliable interconnection.</p>
<p><strong>Java Transaction <acronym title='Application Interface'><span class='caps'>API</span></acronym> (JTA) </strong></p>
<p>JTA is used for managing distributed transactions (e.g. updates to multiple  databases that must be handled in a single transaction). JTA is a low-level <acronym title='Application Interface'><span class='caps'>API</span></acronym>  and associated coding is complex and error-prone.</p>
<p>Fortunately, EJB containers (or application servers) generally provide  support for distributed transactions using JTA. For this reason, the EJB  developer is able to gain the benefit of distributed transaction while leaving  the complex implementation details to the provider of the EJB container.</p>
<p><strong>Java Database Connectivity (<acronym title='Java DataBase Connectivity'><span class='caps'>JDBC</span></acronym>) /  SQLJ</strong></p>
<p>In principle, <acronym title='Java DataBase Connectivity'><span class='caps'>JDBC</span></acronym> serves the same purpose as ODBC.  <acronym title='Java DataBase Connectivity'><span class='caps'>JDBC</span></acronym>  provides a database-independent protocol for accessing relational databases from  Java.  <acronym title='Java DataBase Connectivity'><span class='caps'>JDBC</span></acronym> supports Data Manipulation Language (DML) statements like insert,  update, delete, select.   It also includes Data Definition Language (DDL)  statements like Create Table, Alter Table, etc.</p>
<p><acronym title='Java DataBase Connectivity'><span class='caps'>JDBC</span></acronym> was included in core Java starting with version 1.1.  With  <acronym title='Java DataBase Connectivity'><span class='caps'>JDBC</span></acronym>, the <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> is always dynamically generated at runtime and sent to the  database.</p>
<p>A easier-to-use industry standard for Java database access has  emerged and is called SQLJ.  SQLJ allows static <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> to be used and it requires  less cumbersome syntax than <acronym title='Java DataBase Connectivity'><span class='caps'>JDBC</span></acronym>.  Other SQLJ advantages over <acronym title='Java DataBase Connectivity'><span class='caps'>JDBC</span></acronym> include  better code quality (due to compile-time syntax checking) and better performance  (due to compile-time optimization).  James Woodger co-authored an  in-depth article on SQLJ for the November 2000 issue of Java Enterprise  Developer.</p>
<p><strong>JavaMail /JMC</strong></p>
<p>JavaMail is an independent mail platform which works with major industry  protocols (SMTP, POP3, etc.).</p>
<p>Source <a rel="nofollow" href="http://www.woodger.ca/jv_top.htm">http://www.woodger.ca/jv_top.htm</a></p>
]]></content:encoded>
			</item>
		<item>
		<title>Version 1.8 of Allatori Java Obfuscator is released.</title>
		<link>http://java.AssistProgramming.com/version-18-of-allatori-java-obfuscator-is-released.html</link>
		<pubDate>Mon, 26 Nov 2007 17:53:29 +0000</pubDate>
		<description><![CDATA[Allatori Java Obfuscator belongs to the second generation obfuscators&#8217; family and has all spectrum of opportunities on protection of your intellectual property. In the Allatori arsenal there are the following protection methods: name obfuscation, flow obfuscation, debug info obfuscation, string encryption, watermarking. The obfuscator is free for educational and non-commercial projects.
The 1.8 version has new [...]]]></description>
			<content:encoded><![CDATA[<p><a rel="nofollow" href="http://www.allatori.com">Allatori Java Obfuscator</a> belongs to the second generation obfuscators&#8217; family and has all spectrum of opportunities on protection of your intellectual property. In the Allatori arsenal there are the following protection methods: name obfuscation, flow obfuscation, debug info obfuscation, string encryption, watermarking. The obfuscator is free for educational and non-commercial projects.</p>
<p>The 1.8 version has new fields and methods renaming scheme that makes the resulting jars even smaller, improved control flow obfuscation and enhanced J2ME support.</p>
<p><a rel="nofollow" href="http://www.allatori.com">Allatori Java Obfuscator web site</a> and <a rel="nofollow" href="http://www.allatori.com/downloads/Allatori-1.8-Demo.zip">demo version download</a></p>
]]></content:encoded>
			</item>
		<item>
		<title>Using JavaBeans with JSP. Small Introduction!</title>
		<link>http://java.AssistProgramming.com/using-javabeans-with-jsp-small-introduction.html</link>
		<pubDate>Thu, 20 Sep 2007 07:01:19 +0000</pubDate>
		<description><![CDATA[What should we know when using Java Bean? Here are the most important observations:

A bean class must have a constructor with no arguments. We know that an empty constructor is automatically created.


A bean class shouldn&#8217;t have public instance variables.


 Persistent values should be accessed through methods called get and set. For example name=bean.getName();getName() has no [...]]]></description>
			<content:encoded><![CDATA[<p>What should we know when using Java Bean? Here are the most important observations:</p>
<ul>
<li>A bean class must have a constructor with no arguments. We know that an empty constructor is automatically created.</li>
</ul>
<ul>
<li>A bean class shouldn&#8217;t have public instance variables.</li>
</ul>
<ul>
<li> Persistent values should be accessed through methods called <strong>get </strong>and <strong>set</strong>. For example <code>name=bean.getName();</code>getName() has no arguments and return in a variable the name. Although we can use <acronym title='Java Server Pages'><span class='caps'>JSP</span></acronym> scriptlets or expressions to access arbitrary methods of a class, the standard <acronym title='Java Server Pages'><span class='caps'>JSP</span></acronym> methods are: the getXxx/setXxx or isXxx/setXxx.</li>
</ul>
<p>The <code>jsp:useBean</code> action lets you load a bean to be used in the <acronym title='Java Server Pages'><span class='caps'>JSP</span></acronym> page. Here is the syntax for specifying the using of a bean: <code>&lt;jsp:useBean id="name" class="MyClass" /&gt;</code> Here we initiate an object of  the package class and bind it to the name variable. We also can attach a <strong>scope attribute</strong> that makes the bean associated with more than just the current page.</p>
<p>The local variable has the same type as the object created, but if we want that the variable has the type of a superclass or interface we can use the <strong>type attribute</strong> like here: <code>&lt;jsp:useBean id="name" class="MyClass" type="Runnable" /&gt;</code>;</p>
<p>If we have created a bean we can access its properties with <code>jsp:getProperty</code>. For example the <em>course </em>class has a property called <em>name </em>and we have an instance called <em>java </em>- we can have the value of the <em>period </em>property like this:</p>
<pre>&lt;jsp:getProperty name="java" property="period" /&gt;
&lt;%= java.getPeriod() %&gt;</pre>
<p>If we are not familiar with something like this we can use methods called <strong>getFoo </strong>and  <strong>setFoo </strong>-<strong> </strong>this means the bean has a property of type T called <strong>foo</strong>.</p>
<p>Bellow is an example of a simple bean.</p>
<pre>
public class firstBean {

private String name= "";

public String getName() {

return(name);

}

public void setName(String name) {

this.name= name;

}

}</pre>
<p>Next is an example of using JavaBeans with <acronym title='Java Server Pages'><span class='caps'>JSP</span></acronym>.</p>
<pre>
&lt;jsp:useBean id="user" class="UserData" scope="session"/&gt;
&lt;<acronym title='HyperText Markup Language'><span class='caps'>HTML</span></acronym>&gt;
&lt;BODY&gt;
&lt;blx:getProperty name="user" property="*"&gt;
&lt;FORM METHOD=POST ACTION="SaveName.jsp"&gt;
   What's your name? &lt;INPUT TYPE=TEXT NAME=username SIZE=20&gt;&lt;BR&gt;
   What's your e-mail address? &lt;INPUT TYPE=TEXT NAME=email SIZE=20&gt;&lt;BR&gt;
   What's your age? &lt;INPUT TYPE=TEXT NAME=age SIZE=4&gt;
&lt;P&gt;&lt;INPUT TYPE=SUBMIT&gt;
&lt;/FORM&gt;
&lt;/blx:getProperty&gt;
&lt;/BODY&gt;
&lt;/<acronym title='HyperText Markup Language'><span class='caps'>HTML</span></acronym>&gt;</pre>
<pre>
&lt;<acronym title='HyperText Markup Language'><span class='caps'>HTML</span></acronym>&gt;
&lt;BODY&gt;
&lt;jsp:useBean id="user" class="UserData" scope="session"/&gt;
&lt;blx:setProperty name="user" property="*" onError="errorHandler"/&gt;
&lt;%
  pageContext.include( "GetName.jsp" );
%&gt;
&lt;/BODY&gt;
&lt;/<acronym title='HyperText Markup Language'><span class='caps'>HTML</span></acronym>&gt;</pre>
]]></content:encoded>
			</item>
		<item>
		<title>How to make a java xml post ?</title>
		<link>http://java.AssistProgramming.com/how-to-make-a-java-xml-post.html</link>
		<pubDate>Sat, 08 Sep 2007 15:03:43 +0000</pubDate>
		<description><![CDATA[XML is a great web standard that let you easily pack any kind of informations in a very easy understanding format, that can be easily passed between servers, validated and so on ( For more informations about XML and such u can read articles in our xml category.
Java, the well known OOP language developed by [...]]]></description>
			<content:encoded><![CDATA[<p><acronym title='eXtensible Markup Language'><span class='caps'>XML</span></acronym> is a great web standard that let you easily pack any kind of informations in a very easy understanding format, that can be easily passed between servers, validated and so on ( For more informations about <acronym title='eXtensible Markup Language'><span class='caps'>XML</span></acronym> and such u can read articles in our <a href="http://xml-tips.assistprogramming.com/" title="AssistProgramming.com Xml Tips">xml category</a>.</p>
<p>Java, the well known <acronym title='Object Oriented Programming'><span class='caps'>OOP</span></acronym> language developed by Sun Microsystems, is very very powerful when it comes to communications. We don&#8217;t speak here about the Internet oriented java part that is the beans, servlets stuffs. We are just using java as a desktop  programming language.</p>
<p>As I mentioned before, when it comes to communications, anything i possible in JAVA. Be it sockets or datagrams, client or server program. All are easy to accomplish.</p>
<p>Those being said, you probably need to send a <acronym title='eXtensible Markup Language'><span class='caps'>XML</span></acronym> message to a server, via POST method, because that&#8217;s what this article intends to talk about.  We don&#8217;t want to do here a fancy GUI for that. The purpose of this is only the communication part. The script proposed here will be a console based one. Let&#8217;s consider the snippet:</p>
<pre>
try {        <acronym title='Uniform Resource Locator'><span class='caps'>URL</span></acronym> url = new <acronym title='Uniform Resource Locator'><span class='caps'>URL</span></acronym>(args[0]);String document = args[1];FileReader fr = new FileReader(document);char[] buffer = new char[1024*10];

int b_read = 0;

if ((b_read = fr.read(buffer)) != -1)

{

URLConnection urlc = url.openConnection();

urlc.setRequestProperty("Content-Type","text/xml");

urlc.setDoOutput(true);

urlc.setDoInput(true);

PrintWriter pw = new PrintWriter(urlc.getOutputStream());

pw.write(buffer, 0, b_read);

pw.close();

BufferedReader in = new BufferedReader(new InputStreamReader(urlc.getInputStream()));

String inputLine;

while ((res_line = in.readLine()) != null)

System.out.println(res_line);

in.close();

}

}

catch (Exception e) {

//Threat the exceptions here

}</pre>
<p>This piece of snippet read the <acronym title='eXtensible Markup Language'><span class='caps'>XML</span></acronym> from a file given as the second parameter into the command line and put it into the &#8220;buffer&#8221; object. Off course if you have the xml in an object in your code you can just put it into the buffer object or use your own object. Also the url of the server that post the xml to is given from the command line ( args[0] ).</p>
<p>First we send the buffer&#8217;s content  by setting the connection object to accept input, taking the PrintWriter instance of the connection and writing the contents to it :</p>
<pre>urlc.setDoInput(true);</pre>
<pre>urlc.setDoInput(true);PrintWriter pw = new PrintWriter(urlc.getOutputStream());pw.write(buffer, 0, b_read);</pre>
<p>Next we read the response and print in to the console via an usual method using a BufferedReader object:</p>
<pre>BufferedReader in = new BufferedReader(new InputStreamReader(urlc.getInputStream()));String inputLine;

while ((res_line = in.readLine()) != null)

System.out.println(res_line);</pre>
]]></content:encoded>
			</item>
	</channel>
</rss>
