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

Recommended Answers

All 5 Replies

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();
	}
}
commented: No code tags and not the best example -1
commented: don't help homework kiddos with free code -2

pl replay me how to connect the jdbc in access

pl replay me how to connect the jdbc in access

Here you go

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.