-2

i am trying to call a method of my database class inside my bean. i dont know why it is not working. is it technically wrong? on click of save button i want 1- connect to database 2-insert data.. but i am having this error An Error Occurred: Not supported yet. + Stack Trace + Component Tree + Scoped Variables my page code


my bean

 package DC1;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.event.ActionEvent;

@ManagedBean(name = "ctrbean")
public class ctrbean {

public ctrbean() {
}

private String id ;
private String pa;
private String name;
private String rank;
private String father ;
private String dob ;

public String getId() {
    return id;
}

public void setId(String id) {
    this.id = id;
}

public String getPa() {
    return pa;
}

public void setPa(String pa) {
    this.pa = pa;
}

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

public String getRank() {
    return rank;
}

public void setRank(String rank) {
    this.rank = rank;
}

public String getFather() {
    return father;
}

public void setFather(String father) {
    this.father = father;
}

public String getDob() {
    return dob;
}

public void setDob(String dob) {
    this.dob = dob;
}

public void insert(ActionEvent ee)
{
 avDC1 avd = new avDC1();
 avd.connect();


 }
 }

My Database class

package DC1;

import java.awt.event.ActionEvent;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.bean.ManagedBean;
import javax.inject.Scope;

public class avDC1 {

 public avDC1() {
 }


private ResultSet rs ;

public Connection getConnection() {
    return connection;
}

public void setConnection(Connection connection) {
    this.connection = connection;
}

public ResultSet getRs() {
    return rs;
}

public void setRs(ResultSet rs) {
    this.rs = rs;
}



 public void connect()
 {

try {

    Class.forName("oracle.jdbc.driver.OracleDriver");

} catch (ClassNotFoundException e) {

    System.out.println("Where is your Oracle JDBC Driver?");
    e.printStackTrace();
    return;

 } 

 try {

    connection = DriverManager.getConnection(
            "jdbc:oracle:thin:@localhost:1521:XE", "hr",
            "umair");

 } catch (SQLException e) {

    System.out.println("Connection Failed! Check output console");
    e.printStackTrace();
    return;

 }

 if (connection != null) {
    System.out.println("You made it, take control your database now!");
 } else {
    System.out.println("Failed to make connection!");
 }
 }


public void Searchall(ActionEvent ee)
{
try {
try {

    Class.forName("oracle.jdbc.driver.OracleDriver");

 } catch (ClassNotFoundException e) {

    System.out.println("Where is your Oracle JDBC Driver?");
    e.printStackTrace();
    return;

 }

 try {

    connection = DriverManager.getConnection(
            "jdbc:oracle:thin:@localhost:1521:XE", "hr",
            "umair");

} catch (SQLException e) {

    System.out.println("Connection Failed! Check output console");
    e.printStackTrace();
    return;

}

if (connection != null) {
    System.out.println("You made it, take control your database now!");
} else {
    System.out.println("Failed to make connection!");
}

String  sql = "SELECT * FROM AVIATION" ;

Statement pdt = connection.createStatement();
 //        pdt.setString(1,ID );
 //        pdt.setString(2, panumber);
 //        pdt.setString(3,name);
 //        pdt.setString(4, rank);
 //        pdt.setString(5,father );
 //        pdt.setString(6, dob);

  rs =  pdt.executeQuery(sql);
  rs.next();

  String a = rs.getString("NAME");
  connection.close();

} catch (SQLException ex) {

 Logger.getLogger(avDC1.class.getName()).log(Level.SEVERE, null, ex);

}
} //end of search-all

}//end of class

This is the exception:

java.lang.UnsupportedOperationException: Not supported yet.
    at DC1.person.<init>(person.java:33) 
    at DC1.NewClass.<init>(NewClass.java:22) 
    at DC1.ctrbean.insert(ctrbean.java:76) 
4

1 回答 1

0

DC1.person.java第 33 行明确地抛出了一个UnsupportedOperationException. 也许您或您的同事将其放在那里表明实施尚未完成。否则,您应该删除该语句

throw new UnsupportedOperationException("Not supported yet");
于 2015-08-20T15:48:23.940 回答