jade java と jdbc を使用してデータベースに接続しようとしています
public class IntermediaryAgent extends Agent{
private Connection con;
protected void setup()
{
Class.forName("oracle.jdbc.driver.OracleDriver");
con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1522:xe","hr","hr");
Statement stmt = con.createStatement();
ResultSet rs=stmt.executeQuery("SELECT * FROM data");
rs.next();
int id=rs.getInt(1);
String name=rs.getString("NAME");
String surname=rs.getString("SURNAME");
int age=rs.getInt(4);
System.out.println(""+id+" "+name+" "+surname+" "+age);
rs.close();
stmt.close();
con.close();
DFAgentDescription df=new DFAgentDescription();
df.setName(getAID());
ServiceDescription sd =new ServiceDescription();
sd.setType("Agent");
sd.setName("inter");
df.addServices(sd);
try {
DFService.register(this, df);
} catch (FIPAException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
protected void takeDown()
{
try {
DFService.deregister(this);
} catch (FIPAException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
しかし、私はエラーが発生します
2012-05-24 18:15:27 jade.core.Runtime beginContainer
INFO: ----------------------------------
This is JADE snapshot - revision $WCREV$ of $WCDATE$
downloaded in Open Source, under LGPL restrictions,
at http://jade.tilab.com/
----------------------------------------
2012-05-24 18:15:29 jade.core.BaseService init
INFO: Service jade.core.management.AgentManagement initialized
2012-05-24 18:15:29 jade.core.BaseService init
INFO: Service jade.core.messaging.Messaging initialized
2012-05-24 18:15:29 jade.core.BaseService init
INFO: Service jade.core.mobility.AgentMobility initialized
2012-05-24 18:15:29 jade.core.BaseService init
INFO: Service jade.core.event.Notification initialized
2012-05-24 18:15:29 jade.core.messaging.MessagingService clearCachedSlice
INFO: Clearing cache
2012-05-24 18:15:29 jade.mtp.http.HTTPServer <init>
INFO: HTTP-MTP Using XML parser
com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser
2012-05-24 18:15:29 jade.core.messaging.MessagingService boot
INFO: MTP addresses:
http://10.1.242.245:7778/acc
2012-05-24 18:15:29 jade.core.AgentContainerImpl joinPlatform
INFO: --------------------------------------
Agent container Main-Container@mariusz is ready.
--------------------------------------------
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at agenty.IntermediaryAgent.polacz(IntermediaryAgent.java:120)
at agenty.IntermediaryAgent.setup(IntermediaryAgent.java:19)
at jade.core.Agent$ActiveLifeCycle.init(Agent.java:1519)
at jade.core.Agent.run(Agent.java:1465)
at java.lang.Thread.run(Unknown Source)
*** Uncaught Exception for agent p ***
java.lang.NullPointerException
at agenty.IntermediaryAgent.odczyt(IntermediaryAgent.java:144)
at agenty.IntermediaryAgent.setup(IntermediaryAgent.java:20)
at jade.core.Agent$ActiveLifeCycle.init(Agent.java:1519)
at jade.core.Agent.run(Agent.java:1465)
at java.lang.Thread.run(Unknown Source)
ERROR: Agent p died without being properly terminated !!!
State was 2
jade.domain.FIPAAgentManagement.FailureException: ((action ( agent-identifier :name
df@mariusz:1099/JADE :addresses (sequence http://10.1.242.245:7778/acc )) (deregister
(df-agent-description :name ( agent-identifier :name p@mariusz:1099/JADE :addresses
(sequence http://10.1.242.245:7778/acc ))))) not-registered)
at jade.domain.FIPAService.doFipaRequestClient(FIPAService.java:163)
at jade.domain.FIPAService.doFipaRequestClient(FIPAService.java:102)
at jade.domain.DFService.deregister(DFService.java:195)
at jade.domain.DFService.deregister(DFService.java:217)
at jade.domain.DFService.deregister(DFService.java:228)
at agenty.IntermediaryAgent.takeDown(IntermediaryAgent.java:43)
at jade.core.Agent.clean(Agent.java:1652)
at jade.core.Agent$ActiveLifeCycle.end(Agent.java:1567)
at jade.core.Agent.run(Agent.java:1495)
at java.lang.Thread.run(Unknown Source)
jdbcコードで単純なJavaクラス(エージェントを使用しない)を使用しようとしましたが、動作します。エージェントで jdbc を使用すると、機能しません。なにが問題ですか?