Practical 13 java

JDBC program to fetch data from database
 avatar
Rohit143
java
2 years ago
679 B
44
Indexable
Never
import java.sql.*;
/**
 * jdbcDemo
 */
public class jdbcDemo {

    public static void main(String[] args) throws Exception{
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        Connection connection = DriverManager.getConnection("jdbc:odbc:mydsn");
        Statement statement = connection.createStatement();
        ResultSet resultSet = statement.executeQuery("select * from emp");
        System.out.println("Rohit Nandagawali\n_______________________");

        while (resultSet.next()) {
            System.out.println(resultSet.getInt(1)+" "+resultSet.getString(2)+" "+resultSet.getString(3));

        }
        connection.close();

    }
}