JDBC Tutorial

JDBC Tutorial

What is JDBC? JDBC (Java DataBase Connectivity) is an API which defines how to connect and access a database from Java application. Steps to connect Java application with database Register the driver Class.forName() can be used to explicitly load and register the driver class. From jdbc 4.0 onwards we don’t need to load the driver explicitly. Class.forName("com.mysql.jdbc.Driver"); Create a connection getConnection() of DriverManager class is used to create connection.
Multiple ways of reading a File in Java

Multiple ways of reading a File in Java

Reading a file line by line from File system path using Reader as character stream public void usingBufferReader() throws IOException { BufferedReader br = null; try { File file = new File("D:/Neha/Notes_On_Collections_Java.txt"); FileReader fr = new FileReader(file); br = new BufferedReader(fr); String line; while ((line = br.readLine()) != null) { System.out.println(line); } } catch (FileNotFoundException e) { e.printStackTrace(); } finally { br.close(); } } Reading a file line by line from class path using Reader as character stream public void readFromClassPath() throws IOException { BufferedReader br = null; try { // Get file from resources folder ClassLoader classLoader = getClass().