If you want to use table in blogspot blog and many other blogs using <table> as following way..
<table>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</table>
You'll see a large white spaces before the table. This is for each time you press [ENTER] for new line blogspot generates a line break <br> and when you view the blog you'll find a whitespace for each <br> before the table.
If you want to avoid this unwanted white space just use the following code
<style type="text/css">.eatbr be{ display: none }</style>
<div class="eatbr">
PUT YOUR CODE FOR TABLE HERE
</div>
This will eat <br> inside it..
Happy Blogging...
Java J2ME JSP J2EE Servlet Android
JAVA: Accessing properties file(resource) inside jar
You can not load a properties file inside a jar as following way..
Properties props = new Properties();
props.load(new FileInputStream("conf.properties"));
In this case you have to use
Properties props = new Properties();
InputStream in = this.getClass().getClassLoader().getResourceAsStream("conf.properties");
props.load(in);
I hope this will help you. For any other query you can post question as comment.
Properties props = new Properties();
props.load(new FileInputStream("conf.properties"));
In this case you have to use
Properties props = new Properties();
InputStream in = this.getClass().getClassLoader().getResourceAsStream("conf.properties");
props.load(in);
I hope this will help you. For any other query you can post question as comment.
Oracle DATE to TIMESTAMP
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...
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...
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();
}
}
}
Subscribe to:
Posts (Atom)