Business web hosting - 516 Part IV . Development The getDate(), getTime(),

516 Part IV . Development The getDate(), getTime(), and getTimestamp()methods all return date or time values. When using a getmethod, you provide the column name in quotes. For example, getString( columnname ); If you do not know the column name, you can identify the result with by its numerical column-position reference. If you don t know the number of columns, you can find that value in the realm of the upcoming section; it s a type of metadata. Database metadata To manipulate data, you need information about it metadata. Database metadata, for example, is information about the database and the data it contains for example, the number of columns returned from a query. There are two sets of metadata for JDBC objects connection and result. Both are retrieved with the getMetaData() method. When called in reference to a ResultSet, the ResultSetMetaData object type is returned. In answer to the question posed about the number of columns, the following code snippet shows how to determine the number of columns from a given result set. ResultSetMetaData databaseinfo = result.getMetaData(); int columns = databaseinfo.getColumnCount(); System.out.println(columns); Other useful methods within ResultSetMetaData are getColumnName(), and getColumnType(). Metadata about the database and server is available through the DatabaseMetaData object, as follows: import java.sql.*; public class DBMeta { public static void main(String args[]) { String url = jdbc:mysql://localhost/ecommerce ; Connection con; try { Class.forName( org.gjt.mm.mysql.Driver ); } catch(java.lang.ClassNotFoundException e) { System.err.print( ClassNotFoundException: ); System.err.println(e.getMessage()); } try { con = DriverManager.getConnection(url, suehring , evh5150 );
Please visit Domain Name Hosting services for high quality webhost to host and run your jsp applications.

Leave a Reply