Skip to main content

oracle database connectivity

//note: must be include a jar file ojdbc14.jar

//include in c:\programfiles \java\jdk1.7.0\jre\lib\ext

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

public class prac2
{
public static void main(String args[])a
    {
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");

Connection con =DriverManager.getConnection("jdbc:oracle:thin:@localhost:1000:xe","system","abc");

Statement sta=con.createStatement();
ResultSet rs=sta.executeQuery("select * from student");
while(rs.next())
System.out.println(rs.getInt(1)+" "+rs.getString(2));
con.close();
}
catch(Exception e)
{
System.out.println("error generated"+e);
}
   }
}

Comments

  1. Nice work friend bud i should want to suggest that you want to add some
    Description line for understanding the program
    It must be helpful...

    ReplyDelete
    Replies
    1. Ya it's already included in header, don't worry you can understand easily , or if yo any query say me 👍

      Delete
  2. https://sagarjadav07.blogspot.com/2018/07/marqee-tag.html?m=1
    Must Visit my blog post

    ReplyDelete
  3. Good work doing dear friend
    Follow my blog
    https://www.bhavinvarsur.blogspot.com/

    ReplyDelete

Post a Comment

Popular posts from this blog

how HttpSession work

1)create a 3 page for session program 2)                 create 1 htmlpage 2 javapages(jp)                  1) first(jp) for set attribute and get parameter for html page        2)second(jp) for get attribute and session ID from first java page and display with HttpSession's object HTML PAGE: <html> <body> <form action="http://localhost:8080/session1" method="GET"> NAME:<input type=text name=txt1  placeholder="enter a name here"> <input type="submit" value="submit"> </form> </body> </html> FIRST JAVA PAGE SAVE AS session1.java : import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class session1 extends HttpServlet { public void doGet(HttpServletRequest re1,HttpServletResponse re2) { try { re2.setContentType("text/html"); PrintWriter print=re2.get...

PATHS FOR NEEDED INTO PROGRAMMING ON SERVLET USING APPPACHE TOMCAT 9.0.4

set a 5 path FOR IF YOU WANT TO PROGRAMING IN SERVLET USING APPACHE TOMCAT 9.0.4 CATALINA_HOME: C:\Program Files\Apache Software Foundation\Tomcat 9.0 CLASSPATH: C:\Program Files\Apache Software Foundation\Tomcat 9.0\lib\servlet-api.jar JAVA_HOME: C:\Program Files\Java\jdk1.8.0_121\bin JRE_HOME: C:\Program Files\Java\jdk1.8.0_121\jre path: C:\Program Files\Java\jdk1.8.0_121\bin