resultset metadta

Ads
 

resultset metadta

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;

public class EmployeeDetails{
    public static void main(String[] args) {

        System.out.println("Getting Employee Details Using resultset metadata: ");
        Connection con = null;
        String url = "jdbc:oracle:thin:@172.24.137.30:1521:ORA10G";;

        String driver = "oracle.jdbc.driver.OracleDriver";
        String user = "e206227";
        String pass = "VeuFmodax";
        try{
            Class.forName(driver);
            con = DriverManager.getConnection(url, user, pass);
            try{
                Statement st = con.createStatement();
                ResultSet rs = st.executeQuery("SELECT * FROM employee");
                ResultSetMetaData md = rs.getMetaData();
                while(rs.next())
                {
                    System.out.print("\t"+rs.getString(1));
                    System.out.print("\t"+rs.getString(2));
                    System.out.print("\t"+rs.getString(3));
                    System.out.print("\t"+rs.getString(4));
                    System.out.println("\t"+rs.getString(5));
                }


//              String tableName= md.getTableName(1);
                System.out.println("Table name: "+md.getTableName(5));


                int col = md.getColumnCount();
                System.out.println("Number of Column : "+ col);
                System.out.println("Columns Name: ");
                for (int i = 1; i <= col; i++){
                    String col_name = md.getColumnName(i);

                    System.out.println("\n'"+col_name+"' column properties ");
                    System.out.println("\t max column size: "+md.getColumnDisplaySize(i));
                    System.out.println("\t column type name: "+md.getColumnTypeName(i));
//                  System.out.println("\t catalog name: "+md.getCatalogName(i));
//                  System.out.println("\t Schema name: "+md.getSchemaName(i));
//                  System.out.println("\t Table name: "+md.getTableName(i));
//                  System.out.println("\t catalog name: "+md.getClass());
                    System.out.println("\t is Nullable: "+md.isNullable(i));
                    System.out.println("\t is Currency: "+md.isCurrency(i));
                    System.out.println("\t is Auto increment: "+md.isAutoIncrement(i));
                    System.out.println("\t is case sensitive: "+md.isCaseSensitive(i));
                    System.out.println("\t is Searchable: "+md.isSearchable(i));
                    System.out.println("\t is Writable: "+md.isWritable(i));
                    System.out.println("\t is Signed: "+md.isSigned(i));
                    System.out.println("\t is Read only: "+md.isReadOnly(i));

                }
            }
            catch (SQLException s){
                System.out.println("SQL statement is not executed!");
            }
        }
        catch (Exception e){
            e.printStackTrace();
        }
    }
}
View Answers

Ads









Related Tutorials/Questions & Answers:
resultset metadta
resultset metadta  import java.sql.Connection; import... Employee Details Using resultset metadata: "); Connection con = null...(); ResultSet rs = st.executeQuery("SELECT * FROM employee
ResultSet
ResultSet  I want to retrieve data of unknown datatype from database.how to do it using resultset or Resultsetmetadata.Can you please tell me what... = con.createStatement(); ResultSet rs = st.executeQuery
Advertisements
multiple resultset in one resultset
multiple resultset in one resultset  how to retrive multiple resultsets in one resultset in java.? plz help
Resultset - JSP-Servlet
Resultset  I am writing while(rs.next){} but if resultset is null then it cannot enter in while block. I want,if resultset is null then it will enter into the while block.  Hi friend, A ResultSet object
SQL exception, Exhausted ResultSet
SQL exception, Exhausted ResultSet  javax.servlet.ServletException: java.sql.SQLException: Exhausted Resultset iam getting this error messege whenever i run my code. what would be the possible reasons
JTable populate with resultset.
JTable populate with resultset.  How to diplay data of resultset...) JTable(Vector data, Vector columneNames) Here is a JTable populate with resultset...(); ResultSet resultSet = statement.executeQuery(sql
Resultset Issue in SQL
Resultset Issue in SQL  when i call rs.next() in my code it is returning false, though im having valid query to execute and fetch a row from database.how can i resolve this issue. My code is: SELECT JOBDESCRIPTION,CATEGORY
Resultset with one to many relationship
Resultset with one to many relationship   Suppose there are 5 tables in database named A,B,C,D and E. A has one to many relationship with B,C,D and D... populate my bean classes from resultset without using hibernate, so
ResultSet In Java
ResultSet In Java In this section we will learn about the ResultSet in Java... that are mostly used in to get the value. ResultSet contains the data of a table after executing the SQL queries. Object of ResultSet also maintains the current position
JDBC ResultSet first() Example
JDBC ResultSet first() Example: The ResultSet first() are use to moves the cursor to the first row in the ResultSet object. It return true if the cursor pointed first row in the ResultSet and return false if the ResultSet object does
JDBC ResultSet last() Example
JDBC ResultSet last() Example: The ResultSet last() are use to moves the cursor to the last row in the ResultSet object. It return true if the cursor pointed last row in the ResultSet and return false if the ResultSet object does
Printing Values of Resultset to Html Table
Printing Values of Resultset to Html Table  I have a resultset and I need to collect the resultset values into the arraylist into a table... in advance   JSP Display values of ResultSet to HTML table: <%@page
Spring JdbcTemplate and ResultSet is too slow..
Spring JdbcTemplate and ResultSet is too slow..  Hi.. I am using spring jdbctemplate to fetch the records from oracle database. But it is taking too long time to execute a simple select query. The query which is having 400
Moving Cursor within ResultSet
; } Moving Cursor Within ResultSet There are many methods are given to move... = null; // Statement reference variable for query // Execution ResultSet resultSet = null; // ResultSet reference variable for saving query // result
JDBC Updateable ResultSet Example
; } Updateable ResultSet Example You can update the database table using result set. To update the table using result set you need to set the ResultSet... illustrate how to update table through resultset. UpdateableResultSet.java package
ResultSet Object data to Ms-Word Doc
ResultSet Object data to Ms-Word Doc   help me , i don't know how to write data from oracle database into MSWord document using servlet or jsp
JDBC ResultSet Example
; } JDBC ResultSet Example JDBC ResultSet is an interface of java.sql package... is obtained by executing the execute method of statement. A ResultSet object points...;The default ResultSet object is not updateable therefore the cursor moves only forward
JDBC ResultSet Example
JDBC ResultSet Example: In this example, we are discuss about ResultSet class...) database query results. Through this example you can see how to use ResultSet... statement object and store the result in the resultset object 
JDBC ResultSet beforeFirst() Example
JDBC ResultSet beforeFirst() Example: This ResultSet method set cursor... the cursor is before the first row in this ResultSet object. Syntax: ResultSet rs.... In this example, the beforeFirst() point the 0 position in the resultset object
JDBC ResultSet afterLast() Example
JDBC ResultSet afterLast() Example: This ResultSet method set cursor...() moves the cursor to the end of this ResultSet object, just after the last row...: ResultSet rs; void rs.afterLast(); Now we will create example using this method
JDBC ResultSet Delete Row Example
JDBC ResultSet Delete Row Example: Learn how to delete row using ResultSet. We are also used ResultSet object with update capability for delete rows from...() method on the created statement object to return ResultSet object on the table
Find Default ResultSet Type Example
Find Default ResultSet Type Example: We are discuss about to find out Default ResultSet type. There are many operations depends on the ResultSet support Type so you can find out the default ResultSet type using this example. We
JDBC ResultSet next() Example
JDBC ResultSet next() Example: In this example, we are discuss about resultset... is positioned after the last row. Syntax: ResultSet rs; Boolean rs.next...: package ResultSet; import java.sql.Connection; import 
java.sql.SQLException: Operation not allowed after ResultSet closed
java.sql.SQLException: Operation not allowed after ResultSet closed  package processing; import java.io.; import java.math.BigDecimal; import...(); ResultSet rs = st.executeQuery("Select * from asteriskcdrdb.sp1 where
JDBC ResultSet Scroll Insensitive Type Example
JDBC ResultSet Scroll Insensitive Type Example: Through this ResultSet type... resultset type for MySql. The following syntax are use for initialize the statement object to create a Scroll-Insensitive, read only ResultSet object
JDBC ResultSet Forward Type Example
JDBC ResultSet Forward Type Example: Through this ResultSet type the cursor... only ResultSet object. Statement stmt = connection.createStatement...: package ResultSet; import java.sql.Connection; import 
JDBC ResultSet Scroll Sensitive Type Example
JDBC ResultSet Scroll Sensitive Type Example: Through this ResultSet type... the statement object to create a Scroll-Sensitive, read only ResultSet object..., ResultSet.CONCUR_READ_ONLY); package ResultSet; import 
Executing anonymous pl/sql block and get resultset in Java
Executing anonymous pl/sql block and get resultset in Java  Hello All, I would like to execute the anonymous pl sql block and need to get the resultset object. I got the code which can be done by using cursors inside the pl sql
Rows Count Example Using JDBC ResultSet
Rows Count Example Using  JDBC ResultSet: In this tutorial you can count the number of rows in the database table using ResultSet. Through this example... in the ResultSet as: String selectquery = "select count(*) from user"
Get Column Count using ResultSet in SQL
Get Column Count using ResultSet in SQL   ... of columns in a ResultSet. The ResultSetMetaData object can be obtained by invoking getMetaData() method on ResultSet object. In this program you will see how JDBC
Please tell me how I can access a field (data type char) of resultset in a java class
Please tell me how I can access a field (data type char) of resultset in a java... resultset for this table and tried to access the access empsex as follows: public... = null; ResultSet rset = null; utility.db.Connect c; try

Ads