HDTutorial
EN

Playback starts YouTube’s embedded player (privacy-enhanced mode).

73 Advanced Java Tutorial |JDBC | ResultSetMetaData to print records given database | adv java

4,222 views November 11, 2017 19:10

Watch on YouTube
Channeltech fort

Description from the creator

#Advanced Java Tutorial: adv java - Example Java JDBC application on ResultSetMetaData to print the records of given database table along with columns names & column datatype.

import java.sql.*;
import java.util.*;

public class ResultSetMetaDataWithDataTypes
{
public static void main(String[] args) throws Exception
{
Scanner sc=new Scanner(System.in);
System.out.println("enter the table name");
String tab=sc.next();

//create jdbc connection
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl", "scott", "boss");

//create peristant logic
Statement st=con.createStatement();

ResultSet rs=st.executeQuery("select * from "+tab);

ResultSetMetaData rsmd=rs.getMetaData();
int colCount=rsmd.getColumnCount();

-------------------------------------------------------
-----------------------------------
//close
rs.close();
st.close();
con.close();

}
}

About this tutorial

tech fort published this 19:10 video tutorial on November 11, 2017. It has been watched 4,222 times on YouTube.

Channel
tech fort
Category
Education
Duration
19:10
Published
November 11, 2017
Views
4,222
Likes
82

Tags

Share

This tutorial in other languages