The is a function in oracle name to_timestamp that can transform from CHAR to TIMESTAMP. We can not transform a DATE to TIMESTAMP properly.
Lets consider a table mytab as follows-
mytab
name(CHAR(100)) bdate (DATE)
------------------------------------------------
Mr. Abc 10-10-2009 10:22:22 AM
If we use
SELECT TO_TIMESTAMP(bdate,'DD-MM-RRRR HH24:MI:SS') FROM mytab
we get the value of TO_TIMESTAMP(bdate,'DD-MM-RRRR HH24:MI:SS') as 10-10-2009 00:00:00 AM instead of 10-10-2009 10:22:22 AM. To get proper value of bdate in TIMESTAMP we can first change the DATE to CHAR then CHAR to TIMESTAMP as follows
TO_TIMESTAMP(TO_CHAR(bdate,'DD-MM-RRRR HH24:MI:SS'),'DD-MM-RRRR HH24:MI:SS') FROM mytab
So now
SELECT TO_TIMESTAMP(TO_CHAR(bdate,'DD-MM-RRRR HH24:MI:SS'),'DD-MM-RRRR HH24:MI:SS') FROM mytab
Will give us the value of bdate as TIMESTAMP as 10-10-2009 10:22:22 AM.
I expect your comment on this topic and other questions relating to this topic...
Java J2ME JSP J2EE Servlet Android
A way in java to user bangla number format
The following method will format a double number as thousand lac crore method
with 2 digits after decimal point.
for example 1234567890.987654321 will be formatted as
1,23,45,67,890.99
public static String banglaFormat(double number){
DecimalFormat format1 = new DecimalFormat("#,##0.00");
DecimalFormat format2 = new DecimalFormat("#,##");
DecimalFormat format3 = new DecimalFormat("000.00");
if(number<1000)
return format1.format(number);
double num2 = number/1000;
double num3 = number%1000;
return format2.format(num2)+","+format3.format(num3);
}
with 2 digits after decimal point.
for example 1234567890.987654321 will be formatted as
1,23,45,67,890.99
public static String banglaFormat(double number){
DecimalFormat format1 = new DecimalFormat("#,##0.00");
DecimalFormat format2 = new DecimalFormat("#,##");
DecimalFormat format3 = new DecimalFormat("000.00");
if(number<1000)
return format1.format(number);
double num2 = number/1000;
double num3 = number%1000;
return format2.format(num2)+","+format3.format(num3);
}
Java batch sql execution example
Here is an example of execution batch sql.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
/**
* This is a demo class for batch execution example
*
* @author Sharif Uddin
*
*/
public class BatchExmpl {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
public void batchTest(){
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection connection = DriverManager.getConnection( "jdbc:mysql://localhost:3307/mysql", "root", "");
String sql = "INSER INTO mytab(id,name) VALUES(?,?)";
PreparedStatement pstmt = connection.prepareStatement(sql);
for(int i=1;i<10;i++){
pstmt.setLong(1, i);
pstmt.setString(2, "Name_"+i);
pstmt.addBatch();
}
int updateCount[] = pstmt.executeBatch();
for(int i=0;i
System.out.println(updateCount[i]);
}
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}catch (SQLException e) {
e.printStackTrace();
}
}
}
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
/**
* This is a demo class for batch execution example
*
* @author Sharif Uddin
*
*/
public class BatchExmpl {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
public void batchTest(){
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection connection = DriverManager.getConnection( "jdbc:mysql://localhost:3307/mysql", "root", "");
String sql = "INSER INTO mytab(id,name) VALUES(?,?)";
PreparedStatement pstmt = connection.prepareStatement(sql);
for(int i=1;i<10;i++){
pstmt.setLong(1, i);
pstmt.setString(2, "Name_"+i);
pstmt.addBatch();
}
int updateCount[] = pstmt.executeBatch();
for(int i=0;i
System.out.println(updateCount[i]);
}
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}catch (SQLException e) {
e.printStackTrace();
}
}
}
UNIX Command: ls
Displays a list of the contents of current directory
Synopsis
ls [-a] [-A] [-b] [-c] [-C] [-d] [-f] [-F] [-g] [-i] [-l] [-L] [-m] [-o] [-p] [-q] [-r] [-R] [-s] [-t] [-u] [-x] [pathnames]
ls [-a] [-A] [-b] [-c] [-C] [-d] [-f] [-F] [-g] [-i] [-l] [-L] [-m] [-o] [-p] [-q] [-r] [-R] [-s] [-t] [-u] [-x] [pathnames]
-a Displays all files including hidden files
-A Displays all files including hidden files. But does not display the working directory (.) or the parent directory (..).
-b Force to print non-printable characters to be in octal \ddd notation.
-c Use time of last modification of the i-node (file created, mode changed, and so forth) for sorting (-t) or printing (-l or -n).
-C Multi-column output with entries sorted down the columns.
-d If an argument is a directory it only lists its name not its contents.
-f Force each argument to be interpreted as a directory and list the name found in each slot. This option turns off -l, -t, -s, and -r, and turns on -a; the order is the order in which entries appear in the directory.
-F Mark directories with a trailing slash (/), doors with a trailing greater-than sign (>), executable files with a trailing asterisk (*), FIFOs with a trailing vertical bar (|), symbolic links with a trailing at-sign (@), and AF_Unix address family sockets with a trailing equals sign (=).
-g Same as -l except the owner is not printed.
-i For each file, print the i-node number in the first column of the report.
-l Shows you huge amounts of information (permissions, owners, size, and when last modified.)
-L If an argument is a symbolic link, list the file or directory the link references rather than the link itself.
-m Stream output format; files are listed across the page, separated by commas.
-n The same as -l, except that the owner's UID and group's GID numbers are printed, rather than the associated character strings.
-o The same as -l, except that the group is not printed.
-p Displays a slash ( / ) in front of all directories.
-q Force printing of non-printable characters in file names as the character question mark (?).
-r Reverses the order of how the files are displayed.
-R Includes the contents of subdirectories.
-s Give size in blocks, including indirect blocks, for each entry.
-t Shows you the files in modification time.
-u Use time of last access instead of last modification for sorting (with the -t option) or printing (with the -l option).
-x Displays files in columns.
-1 Print one entry per line of output.
pathnames File or directory to list.
Example
Synopsis
ls [-a] [-A] [-b] [-c] [-C] [-d] [-f] [-F] [-g] [-i] [-l] [-L] [-m] [-o] [-p] [-q] [-r] [-R] [-s] [-t] [-u] [-x] [pathnames]
ls [-a] [-A] [-b] [-c] [-C] [-d] [-f] [-F] [-g] [-i] [-l] [-L] [-m] [-o] [-p] [-q] [-r] [-R] [-s] [-t] [-u] [-x] [pathnames]
-a Displays all files including hidden files
-A Displays all files including hidden files. But does not display the working directory (.) or the parent directory (..).
-b Force to print non-printable characters to be in octal \ddd notation.
-c Use time of last modification of the i-node (file created, mode changed, and so forth) for sorting (-t) or printing (-l or -n).
-C Multi-column output with entries sorted down the columns.
-d If an argument is a directory it only lists its name not its contents.
-f Force each argument to be interpreted as a directory and list the name found in each slot. This option turns off -l, -t, -s, and -r, and turns on -a; the order is the order in which entries appear in the directory.
-F Mark directories with a trailing slash (/), doors with a trailing greater-than sign (>), executable files with a trailing asterisk (*), FIFOs with a trailing vertical bar (|), symbolic links with a trailing at-sign (@), and AF_Unix address family sockets with a trailing equals sign (=).
-g Same as -l except the owner is not printed.
-i For each file, print the i-node number in the first column of the report.
-l Shows you huge amounts of information (permissions, owners, size, and when last modified.)
-L If an argument is a symbolic link, list the file or directory the link references rather than the link itself.
-m Stream output format; files are listed across the page, separated by commas.
-n The same as -l, except that the owner's UID and group's GID numbers are printed, rather than the associated character strings.
-o The same as -l, except that the group is not printed.
-p Displays a slash ( / ) in front of all directories.
-q Force printing of non-printable characters in file names as the character question mark (?).
-r Reverses the order of how the files are displayed.
-R Includes the contents of subdirectories.
-s Give size in blocks, including indirect blocks, for each entry.
-t Shows you the files in modification time.
-u Use time of last access instead of last modification for sorting (with the -t option) or printing (with the -l option).
-x Displays files in columns.
-1 Print one entry per line of output.
pathnames File or directory to list.
Example
UNIX Command: pwd
This is short form of print working directoory. The command is used to display current directory
SYNOPSIS
pwd
Example
pwd
this will print something like
/usr/home
SYNOPSIS
pwd
Example
pwd
this will print something like
/usr/home
Subscribe to:
Posts (Atom)