Created
September 27, 2018 08:47
-
-
Save mihirsam/b51023a3642bc78fe35b4d32ce134ad3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.sql.*; | |
public class UserLogin2 | |
{ | |
public static void main(String args[]) | |
{ | |
try | |
{ | |
//Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); | |
//String url = "jdbc:odbc:Driver={MicrosoftAccessDriver(*.mdb,*.accdb)};DBQ=+"C:\Users\RONITA DEBNATH\Documents\Student.accdb"; | |
Connection conn; | |
conn = DriverManager.getConnection("jdbc:ucanaccess://C:\\Users\\Chandni\\Documents\\Student.accdb"); | |
System.out.println("Connection Successfull"); | |
Statement stmt; | |
stmt = conn.createStatement(); | |
ResultSet rs=stmt.executeQuery("select * from Stu"); | |
if(rs!=null) | |
{ | |
while(rs.next()) | |
{ | |
System.out.println("ID:"+rs.getString(1)+"Name:"+rs.getString(2)); | |
} | |
} | |
stmt.close(); | |
conn.close(); | |
} | |
catch(Exception e) | |
{ | |
System.err.println("got an exception"); | |
System.err.println(e.getMessage()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment