import java.sql.*;
public class connect
{
public static void main(String s[])
{
Connection con=null;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e)
{
System.out.println(e);
}
try
{
con=DriverManager.getConnection("jdbc:odbc:hello");
}
catch(SQLException se)
{
System.out.println(se);
}
System.out.println("Connection is successful");
try
{
String str="select FirstName,LastName,PhoneNo from details";
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery(str);
while(rs.next())
{
System.out.println(rs.getString(1)+" rs.getString(2)+" rs.getString(3));
}
stmt.close();
}
catch(SQLException se)
{
System.out.println(se);
}
}
}
OUTPUT:
Connection is successful
Latha Geetha 44404440
Santhi Kamachi 24500022
No comments:
Post a Comment