Showing posts with label COMPUTER NETWORKS WITH JAVA. Show all posts
Showing posts with label COMPUTER NETWORKS WITH JAVA. Show all posts

Thursday, 29 October 2015

JAVA PROGRAM FOR JAVA AND MS ACCESS CONNECTION

import java.lang.*;
import java.sql.*;
import java.util.*;
import java.io.*;
class jdbcconnection1
{
public static void main(String args[])throws IOException
{
try
{
Connection con;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:ds1");
Statement s=con.createStatement();
ResultSet rs=s.executeQuery("select *from tele1");
while(rs.next())
{
System.out.println("Rollno:"+rs.getString(1));
System.out.println("mark:"+rs.getString(2));
}
con.close();
s.close();
}
catch(Exception e){}
}
}