我试图在bean中创建一个类的对象但是资源管理器说不支持吗?

时间:2015-08-20 15:33:49

标签: java unsupportedoperation

我试图在我的bean中调用我的数据库类的方法。 我不知道为什么它不起作用。 这在技术上是错误的吗? 点击我想要的保存按钮 1-连接到数据库 2插入数据.. 但我有这个错误        发生错误:        尚不支持。       +堆栈跟踪       +组件树       +范围变量 我的网页代码                  
      
      
我的豆子

 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();


 }
 }

我的数据库类

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

这是一个例外:

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) 

1 个答案:

答案 0 :(得分:0)

UnsupportedOperationException第33行明确抛出throw new UnsupportedOperationException("Not supported yet"); 。也许您或您的同事在那里指出实施不完整。否则你应该删除声明

this question