11 thoughts on “JDBC

  1. Exception in thread “main” java.lang.UnsatisfiedLinkError: oracle.jdbc.driver.T2
    CConnection.t2cCreateState([BI[BI[BI[BISI[S[B[BZ)I
    at oracle.jdbc.driver.T2CConnection.t2cCreateState(Native Method)
    at oracle.jdbc.driver.T2CConnection.logon(T2CConnection.java:352)
    at oracle.jdbc.driver.PhysicalConnection.(PhysicalConnection.java:
    454)
    at oracle.jdbc.driver.T2CConnection.(T2CConnection.java:134)
    at oracle.jdbc.driver.T2CDriverExtension.getConnection(T2CDriverExtensio
    n.java:78)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:802)
    at java.sql.DriverManager.getConnection(DriverManager.java:579)
    at java.sql.DriverManager.getConnection(DriverManager.java:221)
    at SelectTest1.main(SelectTest1.java:16)
    Give some solution for this problem sir?

    • Hi Vinod,can you please post your queries in query section.Since its very difficult for us to visit each page to check for queries.

  2. i think you are a wrong version of ojdbc14.jar….

    i studied in some places that if we use wrong version of ojdbc jar file we can get this exception..so try to find out which version you are using..

    if not solved try paste your code and details of database and the location where you collected the jar file from..so that you may get exact help…

  3. if i create one table that consist of usename ,joiningdate for joining date i have used varchar datatype not date .
    then we store date into database table as a string by using java .then what are the drawbacks.

  4. Pingback: Autortrapprove List

  5. sir i am trying execute the program SelectTest1.java.
    an error occured that is sc.nextln() in scanner class using the incompatible datatypes

  6. sir iam trying insert multiple records in db table by gathering their details from end user. but at & error occured. without using & symbol how am take multiple records plz tel me sir.

  7. //NthTest.java
    import java.sql.*;
    import java.util.*;
    public class NthTest
    {
    public static void main(String[] args)throws Exception
    {
    Scanner s=new Scanner(System.in);
    System.out.println(“enter n:”);
    int n=s.nextInt();
    //load jdbc driver class to register jdbc driver
    Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);
    //establish the connection
    Connection con=DriverManager.getConnection(“jdbc:odbc:oradsn”,”scott”,”madhuri”);
    //create jdbc statement object
    Statement st=con.createStatement();
    //send and execute select sql query in db software
    ResultSet rs=st.executeQuery(“select * from emp1 e1 where “+(n-1)+”=(select count(distinct(e2.salary)) from emp1 e2 where e2.salary>e1.salary)”);
    //System.out.println(n+”th highest salary of an employee record is:”);
    while(rs.next())
    {
    System.out.println(rs.getInt(1)+” “+rs.getString(2)+” “+rs.getInt(3));
    }
    //else
    //System.out.println(“no records found”);
    }//main
    };//class

  8. import java.sql.*;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    class MSaccess2 extends JFrame implements ActionListener

    {
    JLabel sid,sname,saddress;
    JTextField t1,t2,t3;
    JButton INSERT;
    Connection con=null;
    PreparedStatement ps=null;

    MSaccess2()
    {
    Container cp=getContentPane();
    cp.setLayout(new FlowLayout());
    cp.setSize(200,200);
    sid=new JLabel(“sid”);
    cp.add(sid);
    t1=new JTextField(10);
    cp.add(t1);
    sname=new JLabel(“sname”);
    cp.add(sname);
    t2=new JTextField(10);
    cp.add(t2);
    saddress=new JLabel(“saddress”);
    cp.add(saddress);
    t3=new JTextField(10);
    cp.add(t3);
    INSERT=new JButton(“INSERT”);
    INSERT.addActionListener(this);
    cp.add(INSERT);
    //create jdbc connection
    try
    {
    Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);
    con=DriverManager.getConnection(“jdbc:odbc:accdsn”);
    //create prepare statement
    PreparedStatement ps=con.prepareStatement(“insert into student786 values(?,?,?)”);

    }

    catch(Exception e)
    {
    e.printStackTrace();
    }
    }
    public void actionPerformed(ActionEvent ae)
    {
    try
    {

    String sid=t1.getText();
    String sname=t2.getText();
    String saddress=t3.getText();
    ps.setString(1,sid);
    ps.setString(2,sname);
    ps.setString(3,saddress);
    int result=ps.executeUpdate();
    if(result==0)
    System.out.println(“records are not inserted”);
    else
    System.out.println(“records are inserted”);
    }
    catch (Exception e)
    {
    e.printStackTrace();
    }
    finally
    {
    try
    {
    ps.close();
    con.close();

    }
    catch (Exception e)
    {
    e.printStackTrace();
    }
    }
    }
    }
    class MSaccess3
    {
    public static void main(String args[])throws Exception
    {

    MSaccess2 mm=new MSaccess2();
    mm.show();
    }

    }

    not inserting record by gui application what is problem with type-1 driver…

Leave a Reply