tag:blogger.com,1999:blog-17739430425393849932024-03-13T00:00:16.700-07:00ERP Java|Free ERP Solution|ERP OpensourceFree ERP Solution with JavaMr. ERPhttp://www.blogger.com/profile/03467723397922543897noreply@blogger.comBlogger92125tag:blogger.com,1999:blog-1773943042539384993.post-79133125168249940522016-07-28T08:45:00.001-07:002016-07-28T08:45:12.929-07:00Opensource ERP Java 2016<span style="background-color: white; color: #6a6a6a; font-family: arial, sans-serif; font-size: x-small; font-weight: bold; line-height: 18.2px;">Recommented</span><br />
<span style="background-color: white; color: #6a6a6a; font-family: arial, sans-serif; line-height: 18.2px;"><b><span style="font-size: x-large;"><br /></span></b></span>
<span style="background-color: white; color: #6a6a6a; font-family: arial, sans-serif; line-height: 18.2px;"><b><span style="font-size: x-large;">opentaps</span></b></span><br />
<span style="background-color: white; color: #6a6a6a; font-family: arial, sans-serif; line-height: 18.2px;"><b><span style="font-size: x-large;"><br /></span></b></span>
<span style="background-color: white; color: #6a6a6a; font-family: arial, sans-serif; font-size: x-small; font-weight: bold; line-height: 18.2px;">opentaps</span><span style="background-color: white; color: #545454; font-family: arial, sans-serif; font-size: x-small; line-height: 18.2px;"> Open Source ERP CRM ecommerce Warehouse Inventory Financials Accounting Purchasing Supply Chain Management Business Intelligence</span><br />
<span style="background-color: white; color: #545454; font-family: arial, sans-serif; font-size: x-small; line-height: 18.2px;"><br /></span>
<span style="background-color: white; color: #006621; font-family: arial, sans-serif; font-size: 14px; line-height: 16px; white-space: nowrap;">www.</span><b style="background-color: white; color: #006621; font-family: arial, sans-serif; font-size: 14px; line-height: 16px; white-space: nowrap;">opentaps</b><span style="background-color: white; color: #006621; font-family: arial, sans-serif; font-size: 14px; line-height: 16px; white-space: nowrap;">.org/</span><br />
<span style="background-color: white; color: #006621; font-family: arial, sans-serif; font-size: 14px; line-height: 16px; white-space: nowrap;"><a href="https://www.google.co.th/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&cad=rja&uact=8&ved=0ahUKEwiz4_33v5bOAhUELo8KHeJtApwQjBAIIjAB&url=http%3A%2F%2Fwww.opentaps.org%2Fproducts%2Fdownload&usg=AFQjCNFJ7RJ3cw7GoXoiySinzAN4arpnIQ&sig2=vzJFVrh-UgrZ1wR0uk3vKg&bvm=bv.128153897,d.c2I" target="_blank">Download opentaps</a></span>Mr. ERPhttp://www.blogger.com/profile/03467723397922543897noreply@blogger.comtag:blogger.com,1999:blog-1773943042539384993.post-23789997762353899172015-08-31T02:04:00.003-07:002015-08-31T02:04:38.270-07:00SQL queries create table example sql command to create table<div style="margin-left: 40px;">
<span style="font-size: 14px;">We can Create table with SQL command for example code below</span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><code><span style="color: teal;">CREATE TABLE table_name(<br />
column_name1 data_type(size),<br />
column_name2 data_type(size),<br />
column_name3 data_type(size));</span></code></span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><span style="color: blue;"><u><strong>Example SQL code for create table</strong></u></span></span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><code><span style="color: teal;">CREATE TABLE Student(<br />
student_id int,<br />
student_name varchar(255));</span></code></span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;">Note: with
difference DBMS the command will not the same for example mysql have
datatype varchar but in Oracle use data type Vaarchar2</span></div>
Mr. ERPhttp://www.blogger.com/profile/03467723397922543897noreply@blogger.comtag:blogger.com,1999:blog-1773943042539384993.post-13371335443736913442015-08-31T02:04:00.000-07:002015-08-31T02:04:03.225-07:00Mysql query for creating table example sql code for create new table with select command<div style="margin-left: 40px;">
<span style="font-size: 14px;">We can create table with <strong>select command</strong> from another table with example<strong> sql command</strong> below</span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><span style="color: mediumblue;"><strong>Example sql command for <u>mysql query for creating table</u></strong></span></span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><span style="color: teal;">CREATE TABLE new_std_table<br />
SELECT * from std_table</span></span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;">you can select with specify field name or using<strong> where condition</strong> ,<strong> group by</strong> , <strong>order by</strong> for example below</span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><span style="color: teal;">CREATE TABLE new_std_table<br />
SELECT std_id,std_name from std_table where std_name like '%anna%' order by std_id</span></span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"> Note: this command will support <strong> MySql DBMS</strong> in other DBMS may be some difference</span></div>
Mr. ERPhttp://www.blogger.com/profile/03467723397922543897noreply@blogger.comtag:blogger.com,1999:blog-1773943042539384993.post-19878161657990175292015-08-31T02:03:00.001-07:002015-08-31T02:03:25.561-07:00Mysql create table int with unsigned int column example sql command<div style="margin-left: 40px;">
<span style="font-size: 14px;">Mysql create table int with unsigned int column example sql command to caeate table with<br />
<u>mysql create unsigned int column</u> and <u>mysql create table unsigned int primary key</u> in below</span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><u><strong>Mysql create unsigned int column</strong></u></span></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;">using key word <u>UNSIGNED</u> after datatype of field for example</span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><code>CREATE TABLE test_table (<br />
test_id INT <span style="color: darkgreen;">UNSIGNED</span> NOT NULL AUTO_INCREMENT,<br />
test_desc TEXT<br />
); </code></span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><strong><u>Mysql create table unsigned int primary key</u></strong></span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<code><span style="font-size: 14px;">CREATE TABLE test_table (<br />
test_id INT <span style="color: darkgreen;">UNSIGNED</span> NOT NULL AUTO_INCREMENT,<br />
test_desc TEXT<br />
<span style="color: blue;">PRIMARY KEY ('test_id')</span><br />
); </span></code></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
Note: using keyword <code><span style="font-size: 14px;"><span style="color: darkgreen;">UNSIGNED</span> </span></code>to tell the data type is <code><span style="font-size: 14px;"><span style="color: darkgreen;">UNSIGNED</span> </span></code>and using keyword <code><span style="font-size: 14px;"><span style="color: blue;">PRIMARY KEY (fieldname)</span></span></code> to tell this field is primary key</div>
Mr. ERPhttp://www.blogger.com/profile/03467723397922543897noreply@blogger.comtag:blogger.com,1999:blog-1773943042539384993.post-12524645886091397762015-08-31T02:01:00.003-07:002015-08-31T02:01:57.974-07:00Spring Framework with Interceptor<div style="margin-left: 40px;">
<span style="font-size: 14px;">Example for using Spring Framework Interceptor for do something before go to Controller </span></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><span style="color: blue;"><u><b>Interceptor Class</b></u></span></span><br />
<br /></div>
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQf6dKwFzveIjpToWLeoaIX2z51HDyAEZMbGk-eTFEUMiu0QQaVDjsqGhAgAgNHmaffoEX2ru4Ma9LIO0R_LPZXcd5jBV94YxPLyEo3aTd-yGI4tYSp3LBw7zQeIFaDoKd7T38EYkA37rf/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> package com.en.interceptor;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import com.en.model.MasterModel;
public class MasterInterceptor extends HandlerInterceptorAdapter{
private String errorURL;
private MasterModel model;
public String getErrorURL() {
return errorURL;
}
public void setErrorURL(String errorURL) {
this.errorURL = errorURL;
}
public MasterModel getModel() {
return model;
}
public void setModel(MasterModel model) {
this.model = model;
}
}
package com.en.interceptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
public class ExampleInterceptor extends MasterInterceptor{
private static Logger logger = Logger.getLogger(ExampleInterceptor.class);
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//request.getRequestDispatcher(errorURL).forward(request, response);
//return false;
logger.info("Interceptor running");
return true;
}
}
</code></pre>
<span style="font-size: 14px;"><span style="color: blue;"><u><b><br /></b></u></span></span>
<span style="font-size: 14px;"><span style="color: blue;"><u><b>Spring Configuration is the same for Spring Bean config</b></u></span><br />
Config to URL Mapping that need to use interseptor </span><br />
<br />
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQf6dKwFzveIjpToWLeoaIX2z51HDyAEZMbGk-eTFEUMiu0QQaVDjsqGhAgAgNHmaffoEX2ru4Ma9LIO0R_LPZXcd5jBV94YxPLyEo3aTd-yGI4tYSp3LBw7zQeIFaDoKd7T38EYkA37rf/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="interceptors">
<list>
<ref local="exampleInterceptor"/>
</list>
</property>
<property name="mappings">
<props>
<prop key="/example_insert.html">exampleController</prop>
<prop key="/example_load.html">exampleController</prop>
<prop key="/example_delete.html">exampleController</prop>
<prop key="/example_ws.html">exampleController</prop>
<prop key="/example_sap.html">exampleController</prop>
</props>
</property>
</bean>
</code></pre>
Mr. ERPhttp://www.blogger.com/profile/03467723397922543897noreply@blogger.comtag:blogger.com,1999:blog-1773943042539384993.post-59924001453445456282015-08-31T01:55:00.001-07:002015-08-31T01:55:17.783-07:00Spring Framework How to use multiaction controller with binding method name<div style="margin-left: 40px;">
<span style="font-size: 14px;">You can use mvc class : org.springframework.web.servlet.mvc.multiaction.PropertiesMethodNameResolver<br />
to bind url to method in MVC Class for example in below</span></div>
<br />
<div style="margin-left: 40px;">
<span style="font-size: 14px;"> <span style="color: blue;"><u><b>CONTROLLER DEFINITIONS</b></u></span></span><br />
<br /></div>
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQf6dKwFzveIjpToWLeoaIX2z51HDyAEZMbGk-eTFEUMiu0QQaVDjsqGhAgAgNHmaffoEX2ru4Ma9LIO0R_LPZXcd5jBV94YxPLyEo3aTd-yGI4tYSp3LBw7zQeIFaDoKd7T38EYkA37rf/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> <bean id="welcomeController" class="com.spring.controller.WelcomeController">
<property name="methodNameResolver" ref="welcomeControllerResolver"/>
</bean>
<bean id="welcomeControllerResolver"
class="org.springframework.web.servlet.mvc.multiaction.PropertiesMethodNameResolver">
<property name="mappings">
<props>
<prop key="/welcome1.cdr">loadWelcome1</prop>
<prop key="/welcome2.cdr">loadWelcome2</prop>
</props>
</property>
</bean>
</code></pre>
<div style="margin-left: 40px;">
<br />
<span style="font-size: 14px;">** loadWelcome1 and loadWelcome2 is method name in Controller class WelcomeController</span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"> <span style="color: blue;"><u><b>URL MAPPING</b></u></span></span><br />
<br /></div>
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQf6dKwFzveIjpToWLeoaIX2z51HDyAEZMbGk-eTFEUMiu0QQaVDjsqGhAgAgNHmaffoEX2ru4Ma9LIO0R_LPZXcd5jBV94YxPLyEo3aTd-yGI4tYSp3LBw7zQeIFaDoKd7T38EYkA37rf/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="/welcome1.cdr">welcomeController</prop>
<prop key="/welcome2.cdr">welcomeController</prop>
</props>
</property>
</bean>
</code></pre>
<div style="margin-left: 40px;">
<br />
<span style="font-size: 14px;">each url can binding to the same controller it's will be defind method mapping in ControllerResolver </span></div>
Mr. ERPhttp://www.blogger.com/profile/03467723397922543897noreply@blogger.comtag:blogger.com,1999:blog-1773943042539384993.post-56848143857782757772015-08-31T01:52:00.002-07:002015-08-31T01:58:58.926-07:00PHP Remove HTML Tag Cleaning Text<div style="margin-left: 40px;">
<span style="font-size: 14px;">We can parse HTML page to collect only normal text with PHP function strip_tags()<br />
for example to using this functoin in bilow</span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><span style="color: blue;"><u><b>Example to using PHP strip_tags()</b></u></span></span><br />
<br /></div>
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQf6dKwFzveIjpToWLeoaIX2z51HDyAEZMbGk-eTFEUMiu0QQaVDjsqGhAgAgNHmaffoEX2ru4Ma9LIO0R_LPZXcd5jBV94YxPLyEo3aTd-yGI4tYSp3LBw7zQeIFaDoKd7T38EYkA37rf/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> $html_page="<a href='test.php'>This is my page </a>";
$txt.=strip_tags($html_page);
</code></pre>
<div style="margin-left: 40px;">
<br />
<span style="font-size: 14px;"><span style="color: blue;"><u><b>The output is return</b></u></span></span></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><span style="background-color: cyan;">This is my page </span><img alt="yes" src="http://www.tutorial66.com/ckeditor/plugins/smiley/images/thumbs_up.png" style="height: 23px; width: 23px;" title="yes" /></span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;">Note** If we have complex HTML page the output is not perfect we need to clean it self for example</span><br />
</div>
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQf6dKwFzveIjpToWLeoaIX2z51HDyAEZMbGk-eTFEUMiu0QQaVDjsqGhAgAgNHmaffoEX2ru4Ma9LIO0R_LPZXcd5jBV94YxPLyEo3aTd-yGI4tYSp3LBw7zQeIFaDoKd7T38EYkA37rf/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> $description.=" ".strip_tags(trim($html_page))." ".$main_term;
$description = ereg_replace( "\n", " ", $description);
$description = ereg_replace( "\r", " ", $description);
$description = ereg_replace( " ", " ", $description);
$description = ereg_replace( " ", " ", $description);
$description = ereg_replace( " ", " ", $description);
$description = ereg_replace( " ", " ", $description);
</code></pre>
Mr. ERPhttp://www.blogger.com/profile/03467723397922543897noreply@blogger.comtag:blogger.com,1999:blog-1773943042539384993.post-42881843272713793092015-08-31T01:51:00.003-07:002015-08-31T01:51:39.631-07:00PHP mysql tutorial example to manage mysql database with PHP<div style="margin-left: 40px;">
<span style="font-size: 14px;">Mysql is the most popular free DBMS with high performance we can use PHP to manage <b>MySQL</b> with query , insert , delete , update<br />
This <b>tutorial </b>is basis for using <b>PHP</b> to execute <b>SQL command</b> pass to <b>MySQL DBMS</b></span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><span style="color: blue;"><u><b>PHP MySQL tutorial</b></u></span></span><br />
<br /></div>
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQf6dKwFzveIjpToWLeoaIX2z51HDyAEZMbGk-eTFEUMiu0QQaVDjsqGhAgAgNHmaffoEX2ru4Ma9LIO0R_LPZXcd5jBV94YxPLyEo3aTd-yGI4tYSp3LBw7zQeIFaDoKd7T38EYkA37rf/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> //Connect database
$username="root";
$password="root";
$database="testdb";
mysql_connect("localhost",$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
//SQL Query command
$query="select * from my_table where p_type='Y' order by last_view desc limit 0,10";
$result=mysql_query($query);
$x_num=mysql_numrows($result);
$x_i=0;
while ($x_i < $x_num) {
$code=mysql_result($result,$x_i,"code_id");
$title=mysql_result($result,$x_i,"title");
echo "<BR>".$code." : ".$title;
}
//SQL Insert / Update Command by using only mysql_query();
$query = "insert into test_comment (flash_id,content,post_by,create_date,last_update,ip) ";
$query.="values('$flash_id','$content2','$post_by','$_date','$_date','$ip')";
mysql_query($query);
$query = "update test_table set stat=$new_stat,last_view='$last_view' where code_id=$code_id";
mysql_query($query);
</code></pre>
<div style="margin-left: 40px;">
<br />
<span style="font-size: 14px;">Tip : you can using command mysql_query(); to execute SQL command to mysql it's very easy <img alt="yes" src="http://www.tutorial66.com/ckeditor/plugins/smiley/images/thumbs_up.png" style="height: 23px; width: 23px;" title="yes" /></span></div>
Mr. ERPhttp://www.blogger.com/profile/03467723397922543897noreply@blogger.comtag:blogger.com,1999:blog-1773943042539384993.post-81182597402006062382015-08-31T01:49:00.003-07:002015-08-31T01:49:28.980-07:00PHP Mysql tutorial for beginners with examples code and tip<div style="margin-left: 40px;">
<span style="font-size: 14px;">PHP Mysql tutorial for beginners with examples code and tip for query with select commans ,<br />
insert delete update with mysql_query();<br />
<br />
<span style="color: blue;"><u><strong>Example PHP Mysql for Connect Database (PHP Mysql tutorial for beginners)</strong></u></span></span></div>
<div style="margin-left: 40px;">
<span style="color: saddlebrown;"><span style="font-size: 14px;">you can use function <strong>mysql_connect();</strong> to connect to mysql dbms by send db host , db user , db password<br />
and use function <strong>mysql_select_db()</strong>; to connect to databalse by send database name for example</span></span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><code><span style="color: teal;">$username="dbuser";<br />
$password="dbpassword";<br />
$database="mydatabase";<br />
mysql_connect("localhost",$username,$password);<br />
//select database if fail print error<br />
@mysql_select_db($database) or die( "Unable to select database");</span></code></span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><span style="color: blue;"><u><strong>Example PHP Mysql for Query with SQL command (PHP Mysql tutorial for beginners)</strong></u></span></span></div>
<div style="margin-left: 40px;">
<span style="color: maroon;"><span style="font-size: 14px;">you can execute any SQL command by sending parameter to functoin <strong>mysql_query();</strong><br />
for example in query it's will return data in <strong>mysql_result();</strong></span></span><br />
</div>
<div style="margin-left: 40px;">
<span style="color: teal;"><code><span style="font-size: 14px;">$query="select * from test_comment where flash_id='$code_id' order by comment_id desc";<br />
$result=mysql_query($query);<br />
$num=mysql_numrows($result);<br />
$i=0;</span></code></span></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><span style="color: teal;"><code>while ($i < $num) {<br />
$content =mysql_result($result,$i,"content");<br />
echo "<br />".$content;<br />
}</code></span></span><br />
</div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><span style="color: blue;"><u><strong>Example PHP Mysql for Insert with SQL command (PHP Mysql tutorial for beginners)</strong></u></span></span></div>
<div style="margin-left: 40px;">
<span style="color: darkgreen;"><span style="font-size: 14px;">for Insert mode it's easy way to using function <strong>mysql_query(); to execute SQL command with insert statement example</strong> code in below</span></span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><span style="color: teal;"><code>$query = "insert into test_comment (flash_id,content,post_by,create_date,last_update,ip) ";<br />
$query.="values('$flash_id','$content2','$post_by','$_date','$_date','$ip')";<br />
mysql_query($query);</code></span></span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><span style="color: blue;"><u><strong>Example PHP Mysql for Delete with SQL command (PHP Mysql tutorial for beginners)</strong></u></span></span></div>
<div style="margin-left: 40px;">
<span style="color: navy;"><span style="font-size: 14px;">for delete mode it's the same way by using <strong>mysql_query();</strong> example code in below\</span></span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><span style="color: teal;"><code>$query = "delete from test_comment ";<br />
mysql_query($query);</code></span></span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><span style="color: blue;"><u><strong>Example PHP Mysql for Update with SQL command (PHP Mysql tutorial for beginners)</strong></u></span></span></div>
<div style="margin-left: 40px;">
<span style="color: green;"><span style="font-size: 14px;">for update mode it's the same <img alt="yes" src="http://www.tutorial66.com/ckeditor/plugins/smiley/images/thumbs_up.png" style="height: 23px; width: 23px;" title="yes" /></span></span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><span style="color: teal;"><code>$query = "update test_comment set title='test' where code_id='1001'";<br />
mysql_query($query);</code></span></span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;">Tip : With PHP and MySQL you can only using mysql_query(); you can send any SQL command to execute <img alt="wink" src="http://www.tutorial66.com/ckeditor/plugins/smiley/images/wink_smile.png" style="height: 23px; width: 23px;" title="wink" /></span></div>
Mr. ERPhttp://www.blogger.com/profile/03467723397922543897noreply@blogger.comtag:blogger.com,1999:blog-1773943042539384993.post-23431509505901589662015-08-31T01:48:00.002-07:002015-08-31T01:48:30.808-07:00Eclipse to uppercase how to switch text between Upper case and Lover case<span style="font-size: 14px;">We can change text from Lower case to upper Case or upper Case to Lower Case by using eclipse shortcut for example in below</span><br />
<br />
<span style="font-size: 14px;"><u><strong>Eclipae shortcut by default for Upper case or Lower case</strong></u></span><br />
<br />
<span style="font-size: 14px;"><span style="color: blue;">Lower case: CTRL+SHIFT+Y<br />
Upper case: CTRL+SHIFT+X </span></span><br />
Mr. ERPhttp://www.blogger.com/profile/03467723397922543897noreply@blogger.comtag:blogger.com,1999:blog-1773943042539384993.post-37172641670022991472015-08-31T01:46:00.001-07:002015-08-31T01:46:16.253-07:00Big Data Tools for quick startup<br /> Apache Hadoop<br />
Apache Hive<br />
Apache HBase<br />
Apache Pig<br />
Apache Storm<br />
Apache Solr<br />
Apache Falcon<br />
Apache Sqoop<br />
Apache Flume<br />
Apache Oozie<br />
Apache Ambari<br />
Apache Mahout<br />
Apache ZooKeeper<br />
Apache KnoxMr. ERPhttp://www.blogger.com/profile/03467723397922543897noreply@blogger.comtag:blogger.com,1999:blog-1773943042539384993.post-70390425423375374962015-08-31T01:42:00.000-07:002015-08-31T01:42:11.755-07:00Oracle Index and tip for using HINT<div style="margin-left: 40px;">
<span style="font-size: 14px;">We can using Index to tunup performance in database<br />
and for more performance in Oracle we can use HINT for select index when query witch example below</span></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><u><strong>Example to create index </strong></u> <br />
<span style="color: teal;">field_a create index name indx_a<br />
field_b create index name indx_b</span></span></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><span style="color: green;">When Query data<br />
select * from my_table where field_a='xxx'; <br />
select * from my_table where field_b='xxx'; <br />
The result is good time response ... very fast <img alt="yes" src="http://www.tutorial66.com/ckeditor/plugins/smiley/images/thumbs_up.png" style="height: 23px; width: 23px;" title="yes" /></span></span></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;">But when using this query</span></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><span style="color: blue;">select * from my_table where field_a='xxx' and field_b='yyy';</span><br />
<span style="color: darkorange;">Can see it's response is not good ... slowly</span></span> <img alt="crying" src="http://www.tutorial66.com/ckeditor/plugins/smiley/images/cry_smile.png" style="height: 23px; width: 23px;" title="crying" /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><span style="color: brown;">I was very confused that why it's not good when we were both of index field in ?<br />
How ever i try to tune up index whtch below it's ok good response and very fast</span><br />
<br />
<span style="color: blue;">create index indx_ab on my_table (field_a,field_b)</span></span></div>
<div style="margin-left: 40px;">
<br /></div>
<span style="font-size: 14px;">But i not think so why ? no need to create more index . <img alt="cool" src="http://www.tutorial66.com/ckeditor/plugins/smiley/images/shades_smile.png" style="height: 23px; width: 23px;" title="cool" /><br />
I try to research and fron the <strong>HINT </strong>we can using HINT to select INdex for example below<br />
<br />
<span style="color: blue;">select /*+INDEX(mt,indx_a)*/ * from my_table mt where field_a='xxx' and field_b='yyy';</span><br />
<br />
It's to fast when query witch no need to create additional index .</span> <img alt="laugh" src="http://www.tutorial66.com/ckeditor/plugins/smiley/images/teeth_smile.png" style="height: 23px; width: 23px;" title="laugh" />Mr. ERPhttp://www.blogger.com/profile/03467723397922543897noreply@blogger.comtag:blogger.com,1999:blog-1773943042539384993.post-45384147212340143512015-08-31T01:41:00.000-07:002015-08-31T01:41:21.667-07:00JSP set content type ms word to export HTML to ms word doc<h5 class="colr">
JSP set content type ms word to export HTML to ms word doc</h5>
<span style="font-size: 14px;">Using response.addHeader() to config header attribute with example</span>
<br />
<br />
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQf6dKwFzveIjpToWLeoaIX2z51HDyAEZMbGk-eTFEUMiu0QQaVDjsqGhAgAgNHmaffoEX2ru4Ma9LIO0R_LPZXcd5jBV94YxPLyEo3aTd-yGI4tYSp3LBw7zQeIFaDoKd7T38EYkA37rf/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> response.addHeader("Content-disposition","attachment; filename=attes.doc");
response.addHeader("Content-Type","application/vnd.ms-word; charset=utf-8");
</code></pre>
Mr. ERPhttp://www.blogger.com/profile/03467723397922543897noreply@blogger.comtag:blogger.com,1999:blog-1773943042539384993.post-45044452687332529142015-08-31T01:33:00.003-07:002015-08-31T01:39:36.222-07:00Java Date Format with SimpleDateFormat<h5 class="colr">
Java Date Format with SimpleDateFormat</h5>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><span style="color: green;">You can use java.text.SimpleDateFormat to farmat Date<br />
For example in below</span></span></div>
<div style="margin-left: 40px;">
<br /></div>
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQf6dKwFzveIjpToWLeoaIX2z51HDyAEZMbGk-eTFEUMiu0QQaVDjsqGhAgAgNHmaffoEX2ru4Ma9LIO0R_LPZXcd5jBV94YxPLyEo3aTd-yGI4tYSp3LBw7zQeIFaDoKd7T38EYkA37rf/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> Date date=new Date();
System.out.println("No format :"+date);
java.text.SimpleDateFormat df= new java.text.SimpleDateFormat();
System.out.println("No pattern format :"+df.format(date));
df.applyPattern("dd/mm/yyyy");
System.out.println("dd/mm/yyyy format :"+df.format(date));
df.applyPattern("dd/mm/yyyy HH:mm:ss");
System.out.println("dd/mm/yyyy HH:mm:ss format :"+df.format(date));
</code></pre>
<div style="margin-left: 40px;">
<br />
<span style="font-size: 14px;"><u><b>Out put when run this code</b></u></span></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><span style="color: blue;">No format :Thu Apr 05 16:29:18 ICT 2012<br />
No pattern format :5/4/2555, 16:29 ?.<br />
dd/mm/yyyy format :05/29/2555<br />
dd/mm/yyyy HH:mm:ss format :05/29/2555 16:29:18</span></span></div>
Mr. ERPhttp://www.blogger.com/profile/03467723397922543897noreply@blogger.comtag:blogger.com,1999:blog-1773943042539384993.post-28354466110109420762015-08-31T01:32:00.003-07:002015-08-31T01:32:54.512-07:00Java ArrayList Example how to use Array List for add content and loop result<div style="margin-left: 40px;">
<span style="font-size: 14px;"><u><b>Exapmple code for using java.utill.ArrayList</b></u></span><br />
<br /></div>
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQf6dKwFzveIjpToWLeoaIX2z51HDyAEZMbGk-eTFEUMiu0QQaVDjsqGhAgAgNHmaffoEX2ru4Ma9LIO0R_LPZXcd5jBV94YxPLyEo3aTd-yGI4tYSp3LBw7zQeIFaDoKd7T38EYkA37rf/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> package example.util;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Vector;
public class ArrayListExample {
public void arrayListExample(){
//Create ArrayList Object
ArrayList arrayList=new ArrayList();
//Store data to ArrayList
arrayList.add("value1");
arrayList.add("value2");
arrayList.add("value3");
arrayList.add("value4");
arrayList.add("value5");
//Test Print all data with toString()
System.out.println("ArrayList Data befor "+arrayList);
//Remove data from ArrayList
String removeValue=arrayList.remove(2);
boolean remove1=arrayList.remove("value1");
boolean remove2=arrayList.remove("value3");
Vector v=new Vector();
v.add("value2");
boolean remove3=arrayList.removeAll(v);
//Removed data can return in VAL
System.out.println("Remove Value "+removeValue);
System.out.println("Remove1 "+remove1);
System.out.println("Remove2 "+remove2);
System.out.println("Remove3 "+remove3);
System.out.println("ArrayList Data after "+arrayList);
//Ged data from ArrayList
System.out.println("-- Example for Get Value from ArrayList --");
System.out.println("Get ArrayList value: "+arrayList.get(0));
System.out.println("Contains ArrayList: "+arrayList.contains("value1"));
System.out.println("Contains ArrayList: "+arrayList.contains("value3"));
//Loop data from Array List
System.out.println("-- Example for Iterate list from ArrayList --");
Iterator it=arrayList.iterator();
while(it.hasNext()){
String value=it.next();
System.out.println("List Iterated Value: "+value);
}
System.out.println("-- Example for Loop from ArrayList --");
for (String temp:arrayList){
System.out.println("For value ArrayList "+temp);
}
}
public static void main (String args[]){
//Test the code in main method
ArrayListExample arryList=new ArrayListExample();
arryList.arrayListExample();
}
}
</code></pre>
<div style="margin-left: 40px;">
<br />
<span style="font-size: 14px;"><u><b>Test Result in below</b></u><br />
<span style="color: purple;">ArrayList Data befor [value1, value2, value3, value4, value5]<br />
Remove Value value3<br />
Remove1 true<br />
Remove2 false<br />
Remove3 true</span><br />
<span style="color: darkgreen;">ArrayList Data after [value4, value5]<br />
-- Example for Get Value from ArrayList --<br />
Get ArrayList value: value4<br />
Contains ArrayList: false<br />
Contains ArrayList: false</span><br />
<span style="color: brown;">-- Example for Iterate list from ArrayList --<br />
List Iterated Value: value4<br />
List Iterated Value: value5</span><br />
<span style="color: saddlebrown;">-- Example for Loop from ArrayList --<br />
For value ArrayList value4<br />
For value ArrayList value5</span></span></div>
Mr. ERPhttp://www.blogger.com/profile/03467723397922543897noreply@blogger.comtag:blogger.com,1999:blog-1773943042539384993.post-90597572180018323642015-08-31T00:09:00.006-07:002015-08-31T00:10:57.532-07:00Java HashSet Example Code for add and collect data from HashSet<div style="margin-left: 40px;">
<span style="font-size: 14px;"><u><b>Example Code for using java.util.HashSet</b></u></span></div>
<div style="margin-left: 40px;">
<br />
<span style="font-size: 14px;">HashSet is a Class in package java.util we can store data and collect data from HashSet like Array</span></div>
<div style="margin-left: 40px;">
<code><span style="font-size: 14px;"> </span></code></div>
<div style="margin-left: 40px;">
<br /></div>
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQf6dKwFzveIjpToWLeoaIX2z51HDyAEZMbGk-eTFEUMiu0QQaVDjsqGhAgAgNHmaffoEX2ru4Ma9LIO0R_LPZXcd5jBV94YxPLyEo3aTd-yGI4tYSp3LBw7zQeIFaDoKd7T38EYkA37rf/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> //Create Instance for HashSet of String
HashSet hashSet=new HashSet();
//Add data to HashSet ...the same way for list
hashSet.add("aa");
hashSet.add("bb");
hashSet.add("ab");
//Check contain data in HashSet
System.out.println("HashSet contails "+hashSet.contains("aa"));
System.out.println("HashSet contails "+hashSet.contains("cc"));
//Loop data in hash Set
Iterator it=hashSet.iterator();
while(it.hasNext()){
System.out.println("HashSet Next Data "+it.next());
}
</code></pre>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><u><b>Result when run program</b></u></span></div>
<div style="margin-left: 40px;">
<br />
<span style="font-size: 14px;"><span style="color: teal;">HashSet contails true<br />
HashSet contails false<br />
HashSet Next Data aa<br />
HashSet Next Data ab<br />
HashSet Next Data bb</span></span></div>
Mr. ERPhttp://www.blogger.com/profile/03467723397922543897noreply@blogger.comtag:blogger.com,1999:blog-1773943042539384993.post-65304585751436536182015-08-31T00:09:00.001-07:002015-08-31T00:09:06.455-07:00Java TreeSet Example to sorting data with java TreeSet<div style="margin-left: 40px;">
<span style="font-size: 14px;">Java TreeSet is a Class int package java.util<br />
We can use TreeSet to auto sorting data in the Tree for example in below</span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><u><b> Example to using java.util.TreeSet</b></u></span></div>
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQf6dKwFzveIjpToWLeoaIX2z51HDyAEZMbGk-eTFEUMiu0QQaVDjsqGhAgAgNHmaffoEX2ru4Ma9LIO0R_LPZXcd5jBV94YxPLyEo3aTd-yGI4tYSp3LBw7zQeIFaDoKd7T38EYkA37rf/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> //Create instance for TreeSet of String
TreeSet treeSet=new TreeSet();
//Store data to TreeSet with mix order
treeSet.add("aa1");
treeSet.add("aa2");
treeSet.add("aa3");
treeSet.add("bb1");
treeSet.add("bb2");
//Test containing data .. the same function for Other Collection
System.out.println("TreeSet contails "+treeSet.contains("aa1"));
System.out.println("TreeSet contails "+treeSet.contains("bb1"));
//Loop data from TreeSet
Iterator it=treeSet.iterator();
while(it.hasNext()){
System.out.println("TreeSet Next Data "+it.next());
}
</code></pre>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><u><b>Result when run program</b></u></span></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><span style="color: teal;"> TreeSet contails true<br />
TreeSet contails true<br />
TreeSet Next Data aa1<br />
TreeSet Next Data aa2<br />
TreeSet Next Data aa3<br />
TreeSet Next Data bb1<br />
TreeSet Next Data bb2</span></span></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;">Amazed !! data will sorting automatic <img alt="yes" src="http://www.tutorial66.com/ckeditor/plugins/smiley/images/thumbs_up.png" style="height: 23px; width: 23px;" title="yes" /></span></div>
Mr. ERPhttp://www.blogger.com/profile/03467723397922543897noreply@blogger.comtag:blogger.com,1999:blog-1773943042539384993.post-45056557190519757122015-08-31T00:06:00.005-07:002015-08-31T00:06:48.092-07:00Java StringBuffer Example to append a lot of String with StringBuffer<div style="margin-left: 40px;">
<span style="font-size: 14px;">When we need to append String with java String we can using a simple Code in below</span></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;">String x="test1";<br />
x=x+"test2" ;</span></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;">With this code have some problem when we adding a lot of String it's not support !! <img alt="surprise" src="http://www.tutorial66.com/ckeditor/plugins/smiley/images/omg_smile.png" style="height: 23px; width: 23px;" title="surprise" /><br />
We have the best solution to append String by using <b>StringBuffer</b> we can append a lot of data <img alt="laugh" src="http://www.tutorial66.com/ckeditor/plugins/smiley/images/teeth_smile.png" style="height: 23px; width: 23px;" title="laugh" /></span></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;">StringBuffer is a Class in paclage java.lang </span></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"> </span><span style="font-size: 14px;"><u><b>Example Code for using StringBuffer</b></u></span></div>
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQf6dKwFzveIjpToWLeoaIX2z51HDyAEZMbGk-eTFEUMiu0QQaVDjsqGhAgAgNHmaffoEX2ru4Ma9LIO0R_LPZXcd5jBV94YxPLyEo3aTd-yGI4tYSp3LBw7zQeIFaDoKd7T38EYkA37rf/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> //Create instance for StringBuffer
StringBuffer stringbuffer =new StringBuffer();
//Append String to StringBuffer
stringbuffer.append("str1");
stringbuffer.append("str2");
stringbuffer.append("str3");
/*
..
.. You can append a lot of data you want
..
*/
//Transform it to String
String data=stringbuffer.toString();
System.out.println("StringBuffer data :"+data);
</code></pre>
<span style="font-size: 14px;"><b> </b><u><b>Out put when Run Program</b></u></span>
<br />
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><span style="color: teal;">StringBuffer data :str1str2str3</span></span></div>
<div style="margin-left: 40px;">
<br /></div>
Mr. ERPhttp://www.blogger.com/profile/03467723397922543897noreply@blogger.comtag:blogger.com,1999:blog-1773943042539384993.post-79827006641999089472015-08-31T00:04:00.005-07:002015-08-31T00:04:58.246-07:00Java Hashmap Example example code to using Hashmap in Java<div style="margin-left: 40px;">
<span style="font-size: 14px;">HashMap is a Collection Class in package java.util<br />
HashMap store data with key and value for example in below</span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><u><b>Example to using HashMap in Java</b></u></span></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><u><b><br /></b></u></span></div>
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQf6dKwFzveIjpToWLeoaIX2z51HDyAEZMbGk-eTFEUMiu0QQaVDjsqGhAgAgNHmaffoEX2ru4Ma9LIO0R_LPZXcd5jBV94YxPLyEo3aTd-yGI4tYSp3LBw7zQeIFaDoKd7T38EYkA37rf/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> package example.util;
import java.util.*;
public class HashmapExample {
public void hashmapExample(){
//Create HashMap Object
HashMap<String,String> hashmap=new HashMap<String,String>();
//Store and Remove data from HashMap
hashmap.put("key1", "value1");
hashmap.put("key2", "value2");
hashmap.put("key3", "value3");
String key3=hashmap.remove("key3");
//Get Value from HashMap by using Key
System.out.println("-- Example for Get Value from HashMap --");
System.out.println("Get Hashmap value: "+hashmap.get("key1"));
System.out.println("Remove Hashmap value: "+key3);
System.out.println("Contains Key Hashmap: "+hashmap.containsKey("key1"));
System.out.println("Contains Key Hashmap: "+hashmap.containsKey("key3"));
System.out.println("Contains Value Hashmap: "+hashmap.containsValue("value1"));
System.out.println("Contains Value Hashmap: "+hashmap.containsValue("value3"));
//Loop data from HashMap by keySet and using key to get the Value
System.out.println("-- Example for Iterate list from Hash Map --");
Iterator<String> it=hashmap.keySet().iterator();
while(it.hasNext()){
String key=it.next();
String value=hashmap.get(key);
System.out.println("By Key :Key : "+key+" Value: "+value);
}
//Loop data from HashMap by Value List all value no need to using Key
it=hashmap.values().iterator();
while(it.hasNext()){
System.out.println("Value "+it.next());
}
}
public static void main (String args[]){
//Test run program in main method
HashmapExample hashmap=new HashmapExample();
hashmap.hashmapExample();
}
}
</code></pre>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><u><b>Output when Run Test Program</b></u></span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><span style="color: teal;">-- Example for Get Value from HashMap --<br />
Get Hashmap value: value1<br />
Remove Hashmap value: value3<br />
Contains Key Hashmap: true<br />
Contains Key Hashmap: false<br />
Contains Value Hashmap: true<br />
Contains Value Hashmap: false<br />
-- Example for Iterate list from Hash Map --<br />
By Key :Key : key2 Value: value2<br />
By Key :Key : key1 Value: value1<br />
Value value2<br />
Value value1</span></span></div>
<div style="margin-left: 40px;">
<br /></div>
Mr. ERPhttp://www.blogger.com/profile/03467723397922543897noreply@blogger.comtag:blogger.com,1999:blog-1773943042539384993.post-16256012871304819612015-08-31T00:02:00.003-07:002015-08-31T00:02:25.860-07:00Java Hashtable Example Code for using Hashtable store data and get data<div style="margin-left: 40px;">
<span style="font-size: 14px;"><span style="color: blue;"><b>You can use Hasetable to atore data with key and value for example</b></span><br />
key1= data1<br />
key2= data 2<br />
key3= data 3</span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;">you can use key collect data from <u>Hashtable</u> however you can collect list of key or value with keySet and valuesSet</span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;">Example Code to using java Hashtable<br />
** you need to inport java.util package</span></div>
<div style="margin-left: 40px;">
<br /></div>
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQf6dKwFzveIjpToWLeoaIX2z51HDyAEZMbGk-eTFEUMiu0QQaVDjsqGhAgAgNHmaffoEX2ru4Ma9LIO0R_LPZXcd5jBV94YxPLyEo3aTd-yGI4tYSp3LBw7zQeIFaDoKd7T38EYkA37rf/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> package example.util;
import java.util.*;
public class HashtableExample {
public void hashtableExample(){
//Create Hashtable Object
Hashtable<String,String> hashtable=new Hashtable<String,String>();
//Store and Remove data from Hashtable
hashtable.put("key1", "value1");
hashtable.put("key2", "value2");
hashtable.put("key3", "value3");
String key3=hashtable.remove("key3");
System.out.println("-- Example for Get Value from Hashtable --");
System.out.println("Get Hashtable value: "+hashtable.get("key1"));
System.out.println("Remove Hashtable value: "+key3);
System.out.println("Contains Key Hashtable: "+hashtable.containsKey("key1"));
System.out.println("Contains Key Hashtable: "+hashtable.containsKey("key3"));
System.out.println("Contains Value Hashtable: "+hashtable.containsValue("value1"));
System.out.println("Contains Value Hashtable: "+hashtable.containsValue("value3"));
System.out.println("-- Example for Iterate list from Hashtable --");
Iterator<String> it=hashtable.keySet().iterator();
while(it.hasNext()){
String key=it.next();
String value=hashtable.get(key);
System.out.println("By Key :Key : "+key+" Value: "+value);
}
it=hashtable.values().iterator();
while(it.hasNext()){
System.out.println("Value "+it.next());
}
}
public static void main (String args[]){
HashtableExample hashtable=new HashtableExample();
hashtable.hashtableExample();
}
}
</code></pre>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><u><strong>Result when run test</strong></u></span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="color: teal;"><span style="font-size: 14px;">-- Example for Get Value from Hashtable --<br />
Get Hashtable value: value1<br />
Remove Hashtable value: value3<br />
Contains Key Hashtable: true<br />
Contains Key Hashtable: false<br />
Contains Value Hashtable: true<br />
Contains Value Hashtable: false<br />
-- Example for Iterate list from Hashtable --<br />
By Key :Key : key2 Value: value2<br />
By Key :Key : key1 Value: value1<br />
Value value2<br />
Value value1</span></span></div>
Mr. ERPhttp://www.blogger.com/profile/03467723397922543897noreply@blogger.comtag:blogger.com,1999:blog-1773943042539384993.post-55114765876226713332015-08-30T22:01:00.003-07:002015-08-30T22:01:47.604-07:00Java synchronized block vs synchronized method<div style="margin-left: 40px;">
<span style="font-size: 14px;">You can using synchronized to lock multi Thread program with process thread by thread </span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><span style="color: blue;"><strong>Example code for using synchronized block and synchronized method</strong></span></span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><u><span style="color: blue;"><strong>synchronized method</strong></span></u></span></div>
<div style="margin-left: 40px;">
<br />
<span style="font-size: 14px;"><code>public synchronized void testMethod(String obj){<br />
// you method logic <br />
}</code></span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><u><strong><span style="color: blue;">synchronized block</span></strong></u></span></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><code>public void testMethod(String obj){<br />
// your method logic<br />
synchronized(this){<br />
// your method logic<br />
// your method logic<br />
}<br />
// your method logic<br />
// your method logic<br />
synchronized(Test.class){<br />
// your method logic<br />
// your method logic<br />
}<br />
// your method logic<br />
}</code></span></div>
Mr. ERPhttp://www.blogger.com/profile/03467723397922543897noreply@blogger.comtag:blogger.com,1999:blog-1773943042539384993.post-28763951504106645252015-08-30T21:50:00.000-07:002015-08-30T21:50:02.871-07:00Java enum valueof example code for valueof method in java enum<div style="margin-left: 40px;">
<span style="font-size: 14px;"><u>enum </u> is the common base class of all Java language <u>enumeration types</u>. including descriptions of the implicitly declared methods synthesized by the compiler<br />
<u>valueof</u> method returns the enum constant of the specified enum
type with the specified name. The name must match exactly an identifier
used to declare an enum constant in this type</span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><u><b>Method syntax</b></u></span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;">public static > T valueOf(Class enumType, String name)</span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><u><b>Method input parameter</b></u></span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"> enumType - the Class object of the enum type from which to return a constant<br />
name - the name of the constant to return</span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><u><b>Method return</b></u> </span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;">the enum constant of the specified enum type with the specified name</span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><u><b>Example Code for java enum valueof</b></u></span></div>
<div style="margin-left: 40px;">
<br /></div>
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQf6dKwFzveIjpToWLeoaIX2z51HDyAEZMbGk-eTFEUMiu0QQaVDjsqGhAgAgNHmaffoEX2ru4Ma9LIO0R_LPZXcd5jBV94YxPLyEo3aTd-yGI4tYSp3LBw7zQeIFaDoKd7T38EYkA37rf/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> enum Car {
City(800000), Civic(1200000),Jaz(850000);
int price;
Car(int p) {
price = p;
}
int showPrice() {
return price;
}
}
public class EnumTest {
public static void main(String args[]) {
System.out.println("My Car List:");
for(Car m : Car.values()) {
System.out.println(m + " Price " + m.showPrice());
}
Car city;
city = Car.valueOf("City");
System.out.println("Test Selected Car : " + city);
}
}
</code></pre>
<br />
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><u><b>Runnint Result</b></u></span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;">My Car List:<br />
City Price 800000<br />
Civic Price 1200000<br />
Jaz Price 850000<br />
Test Selected Car : City</span></div>
Mr. ERPhttp://www.blogger.com/profile/03467723397922543897noreply@blogger.comtag:blogger.com,1999:blog-1773943042539384993.post-54204644030095238612015-08-30T21:47:00.003-07:002015-08-30T21:47:52.782-07:00Java hashmap get value by key example code for java hashmap<div style="margin-left: 40px;">
we can call <u>method get </u>to Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.</div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><u><strong>Method syntax</strong></u></span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
public V get(Object key)</div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><u><strong>Method input parameter</strong></u></span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"> </span>key - the key whose associated value is to be returned</div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><u><strong>Method return</strong></u> </span></div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
the value to which the specified key is mapped, or null if this map contains no mapping for the key</div>
<div style="margin-left: 40px;">
<br /></div>
<div style="margin-left: 40px;">
<span style="font-size: 14px;"><u><strong>Example Code for java enum valueof</strong></u></span></div>
<div style="margin-left: 40px;">
<br /></div>
<span style="color: teal;"><code> HashMap hm=new HashMap();<br />
hm.put("key1", "data1");<br />
hm.put("key2", "data2");<br />
String data=hm.get("key1");<br />
System.out.println(data);</code></span>Mr. ERPhttp://www.blogger.com/profile/03467723397922543897noreply@blogger.comtag:blogger.com,1999:blog-1773943042539384993.post-19987185722012938962015-08-30T21:14:00.001-07:002015-08-30T21:14:39.822-07:00Javascript popup window onclick example to open URL with Popup<span style="font-size: 14px;">You can open new popup windows with function <u><strong>window.open()</strong></u> send URL and optional option in parameter<br />
<span style="color: purple;">window.open("URL" , "Target", "Option");</span><br />
<strong>URL :</strong> url you want to link to<br />
<strong>Target :</strong> _blank , _self<br />
<strong>Option :</strong> you can customize display option eg. display toolbar ? , scrollbars ? . you can config display position and pop up size.<br />
for example in below<br />
<br />
<span style="color: blue;"><u><strong>Example for open url popup windows with java script</strong></u></span></span>
<pre style="font-family:arial;font-size:12px;border:1px dashed #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;;background-image:URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQf6dKwFzveIjpToWLeoaIX2z51HDyAEZMbGk-eTFEUMiu0QQaVDjsqGhAgAgNHmaffoEX2ru4Ma9LIO0R_LPZXcd5jBV94YxPLyEo3aTd-yGI4tYSp3LBw7zQeIFaDoKd7T38EYkA37rf/s320/codebg.gif);padding:0px;color:#000000;text-align:left;line-height:20px;"><code style="color:#000000;word-wrap:normal;"> <script>
// Create array of String
arrayObj=["CAT","DOG","MAN","CAR"];
for (var i=0;i<arrayObj.length;i++)
document.write(arrayObj[i] + "<br>");
}
</script>
</code></pre>Mr. ERPhttp://www.blogger.com/profile/03467723397922543897noreply@blogger.comtag:blogger.com,1999:blog-1773943042539384993.post-9858654218249843962015-08-30T20:46:00.001-07:002015-08-30T21:13:00.221-07:00Javascript array loop example code for loop array in javascript<script><br> // Create array of String<br> arrayObj=["CAT","DOG","MAN","CAR"];<br> for (var i=0;i<arrayObj.length;i++)<br> document.write(arrayObj[i] + "<br>");<br> }<br></script>You can loop data in<b> </b><u><b>javascript array</b></u> by using index and limit with <u><b>array.length</b></u> for example code in below<br />
<br />
<pre style="font-family:arial;font-size:12px;border:1px dashed #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;;background-image:URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQf6dKwFzveIjpToWLeoaIX2z51HDyAEZMbGk-eTFEUMiu0QQaVDjsqGhAgAgNHmaffoEX2ru4Ma9LIO0R_LPZXcd5jBV94YxPLyEo3aTd-yGI4tYSp3LBw7zQeIFaDoKd7T38EYkA37rf/s320/codebg.gif);padding:0px;color:#000000;text-align:left;line-height:20px;"><code style="color:#000000;word-wrap:normal;"> <script>
// Create array of String
arrayObj=["CAT","DOG","MAN","CAR"];
for (var i=0;i<arrayObj.length;i++)
document.write(arrayObj[i] + "<br>");
}
</script>
</code></pre>
<br />
The out put is<br />
<br />
CAT<br />
<br />
DOG<br />
<br />
MAN<br />
<br />
CAR
Mr. ERPhttp://www.blogger.com/profile/03467723397922543897noreply@blogger.com