kindly please tell me how to connect from java to ms access, sql,oracle and so etc . with example

There are a choke full of online resources out there for the same. A simple google search for "connect to oracle using java" should be good to go.

import java.io.*;
import java.sql.*;
import java.net.*;

public class sqlDemo1
{
	int eno;
	ResultSet rs;
	ResultSetMetaData md;
	String /*insq,*/ selq;
	Statement stmt;
	
	public sqlDemo1()
	{
		try
		{
			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
			Connection con=DriverManager.getConnection("jdbc:odbc:javadb");
			
			//BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
			//System.out.println("Enter Employee id");
			//eno=Integer.parseInt(br.readLine());

			stmt=con.createStatement();
			selq="select * from emp";
			

			//insq="insert into emp values(?,?,?)";
			//int j=stmt.executeUpdate(insq);
			//System.out.println("No of rows inserted \t" +j);
			
			rs=stmt.executeQuery(selq);
			md=rs.getMetaData();
			int col=md.getColumnCount();
			
			while(rs.next())
			{
				for(int i=0; i <= col; i++)
				{
					System.out.print(rs.getString(i) + "\t");
					//rs.next();
				}
				System.out.println();
			}
		
			rs.close();
			stmt.close();
			con.close();
		}
		
		catch(Exception e)
		{
			e.printStackTrace();
		}
	}
	
	public static void main(String args[]) throws Exception
	{
		new sqlDemo1();
	}
}

Edited 6 Years Ago by ~s.o.s~: Added code tags, please learn to use them.

Comments
don't help homework kiddos with free code
No code tags and not the best example
This article has been dead for over six months. Start a new discussion instead.