Simple Data Base
Excersise: 16
Program
import java.io.*;
import java.sql.*;
public class jdbc
{
public static void main(String[] arg)
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:123","","");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("Select *From aa");
ResultSetMetaData rsmd=rs.getMetaData();
int numberOfColumns=rsmd.getColumnCount();
while(rs.next())
{
for(int i=1;i<=numberOfColumns;i++)
{
if(i>1)
System.out.println(",");
String columnValue=rs.getString(i);
System.out.print(columnValue);
}
System.out.println(" ");
}
st.close();
con.close();
}
catch(Exception ex)
{
System.err.print("Exception:");
System.err.println(ex.getMessage());
}
}
}
Output
I learn for your blog thanks for your information
ReplyDeleteYour all post are valuable and useful...
ReplyDeleteThank you for your good information
Post a Comment
Thanks for your comments. Please be visit and given positive review on our site.