[JSP / Servlet] Get value from DB


Writing time : 2014-01-28 21:45:52

Get value from DB

When using a ResultSet object to get a value from DB, you can get a value with the getInt, getLong, and getString methods of the ResultSet object.

The getTimestamp method is used to get the data declared as timestamp in the MySQL database table. To convert the Timestamp object returned by the method into a string, refer to the getTime method below.

private String getTime(Timestamp time){  
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
return formatter.format(time.getTime());  
}  
Previous post

Other posts in the category