Showing posts with label JAVA. Show all posts
Showing posts with label JAVA. Show all posts

Monday, 28 December 2015

Connecting to Access Database using JDBC-ODBC Bridge Driver

To connect a Java application with Access database using JDBC-ODBC Bridge  Driver. You need to follow the following steps

Create DSN Name:

1.Go to Control panel:
2.Go to Administrative tools:

 3.Select datasource(ODBC):

4.Add New DSN Name,select Add:


5.Select Access driver from the list,click on finish:


6.Give a DSN name, click ok:

Example:

We suppose that you have created a student table with sid and name column name in access database.

import java.sql.*;
class Test
{
public static void main(String []args)
{
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:Test", "", "");
Statement s=con.createStatement(); //creating statement
ResultSet rs=s.executeQuery("select * from student"); //executing statement
while(rs.next()){
System.out.println(rs.getInt(1)+" "+rs.getString(2));
}
con.close(); //closing connection
}catch(Exception e)
{
e.printStackTrace();
}
}
}

 

Friday, 25 December 2015

Java JDBC Tutorial

--------------------------------------------------------------------------------------------------------------
  • Java JDBC is a java API(Application programming interface) to connect and execute query with the database. JDBC API uses jdbc drivers to connect with the database.
  • Before JDBC, ODBC API was the database API to connect and execute query with the database. 
  • But, ODBC API uses ODBC driver which is written in C language (i.e. platform dependent and unsecured). 
  • That is why Java has defined its own API (JDBC API) that uses JDBC drivers (written in Java language). 
  1. JDBC Driver
  2. Steps to connect to the Database 
  3. Connecting to Access Database using JDBC-ODBC Bridge Driver 



Thursday, 20 November 2014

Method Overloading

What is Method overloading?
                                    A class is have two or more methods having same name,but their argument lists are different(Number of Parameters,data type of paraameters,Sequence of Data type of parameters) it is called method overloading.
It is also known as Static Polymorphism.
Advantages: It increases the readability of the program
--------------------------------------------------------------
Example 1: Different number of parameters in the argument list
class calc
{
void add(int a,int b)
{
System.out.pritnln(a+b);
}
void add(int a,int b,int c)
{
System.out.pritnln(a+b+c);
}
public static void main(String args[])
{
calc obj1=new calc();
obj1.add(10,20,30);
obj1.add(10,20);
}
}
OUTPUT:60
             30
--------------------------------------------------------------
Example 2: Difference in data type of argument 
class calc
{
void add(int a,int b)
{
System.out.pritnln(a+b);
}
void add(float a,float b )
{
System.out.pritnln(a+b);
}
public static void main(String args[])
{
calc obj1=new calc();
obj1.add(10.5,10.5)
obj1.add(10,20);
}
}
OUTPUT:21
             30
--------------------------------------------------------------






Wednesday, 19 November 2014

OOPS CONCEPTS IN JAVA




1.Method overloading  2. Method overriding  3. Exception handling 
4. Method overloading vs Overriding   5. Constructors 6. Constructor overloading
7. private constructor 8. Constructors in interfaces 9. Constructor chaining
10. Aggregation 11. Association 12. OOPs basics
13. Polymorphism in java   14. Types of polymorphism 15. Inheritance
16. Types of inheritance 17. Hybrid inheritance 18. Hierarchical inheritance
19. Multilevel inheritance 20. Multiple inheritance 21. Encapsulation
22. Static and dynamic binding in java 23. Static class 24. Static methods
25. Static variables 26. Static import 27. Static constructor
28. Inner classes 29. Abstract class and methods 30. Interfaces in java
31. Abstract class vs interface 32. Access modifiers 33. Packages in java
34. Final Keyword 35. Super keyword

HOW TO STOP WINDOWS 10 AUTO UPDATE