java - 如何从不同的包中调用类
问题描述
大家早上好,当我想用不同的包裹打电话给我的班级时,我遇到了问题。我有用
private void getExecutionReport(quickfix.Message message, String tipeMessage) {
// TODO Auto-generated method stub
try {
System.out.print("Message "+ message);
StringField msgType = message.getHeader().getField(new MsgType());
System.out.print("getExecutionReport "+tipeMessage);
String symbol = message.getString(Symbol.FIELD);
System.out.print("getExecutionReport "+symbol);
String clorid = message.getString(ClOrdID.FIELD);
String orderid = message.getString(OrderID.FIELD);
String execid = message.getString(ExecID.FIELD);
String execTransType = message.getString(ExecTransType.FIELD);
String ordertype = message.getString(OrdType.FIELD);
String exectype = message.getString(ExecType.FIELD);
String orderstatus = message.getString(OrdStatus.FIELD);
int side = message.getInt(Side.FIELD);
Double orderqty = message.getDouble(OrderQty.FIELD);
int leavesqty = message.getInt(LeavesQty.FIELD);
double price = message.getDouble(Price.FIELD);
int cumqty = message.getInt(CumQty.FIELD);
int lastqty = message.getInt(LastQty.FIELD);
//call Class in different package
DAOInsert.newOrderSingleInsert(tipeMessage,symbol,clorid,orderid,execid,execTransType,ordertype,exectype,orderstatus,side,orderqty,leavesqty,price,cumqty,lastqty);
} catch (FieldNotFound e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
但是当我想上这门课时
public class DAOInsert {
private DAOInsert dAOInsert;
static Session sessionObj;
static SessionFactory sessionFactoryObj;
public final static Logger logger = Logger.getLogger(DAOInsert.class);
// This Method Is Used To Create The Hibernate's SessionFactory Object
private static SessionFactory buildSessionFactory() {
// Creating Configuration Instance & Passing Hibernate Configuration File
Configuration configObj = new Configuration();
configObj.configure("hibernate.cfg.xml");
// Since Hibernate Version 4.x, ServiceRegistry Is Being Used
ServiceRegistry serviceRegistryObj = new StandardServiceRegistryBuilder().applySettings(configObj.getProperties()).build();
// Creating Hibernate SessionFactory Instance
sessionFactoryObj = configObj.buildSessionFactory(serviceRegistryObj);
return sessionFactoryObj;
}
public static void newOrderSingleInsert(String tipeMessage, String symbol, String clorid, String orderid, String execid, String execTransType, String ordertype, String exectype, String orderstatus, int side, Double orderqty, int leavesqty, double price, int cumqty, int lastqty){
int count = 0;
NewOrderSingle newordersingleObj = null;
try {
System.out.print("DAOInsert "+tipeMessage);
// Getting Session Object From SessionFactory
sessionObj = buildSessionFactory().openSession();
// Getting Transaction Object From Session Object
sessionObj.beginTransaction();
// Creating Transaction Entities
// newordersingleObj = new NewOrderSingle();
//newordersingleObj.setFixProtocol("FIX.4.2");
//newordersingleObj.setBodyLength(250);
//sessionObj.save(newordersingleObj);
// Committing The Transactions To The Database
//sessionObj.getTransaction().commit();
//logger.info("\nSuccessfully Created '" + count + "' Records In The Database!\n");
} catch(Exception sqlException) {
if(null != sessionObj.getTransaction()) {
logger.info("\n.......Transaction Is Being Rolled Back.......\n");
sessionObj.getTransaction().rollback();
}
sqlException.printStackTrace();
} finally {
if(sessionObj != null) {
sessionObj.close();
}
}
}
}
我无法使用我的第一种方法来上课。我上课时有什么问题?请帮我解决我的问题
解决方案
推荐阅读
- javascript - 我的 ajax 调用返回带有 html 代码的数据
- javascript - 拖动png图像时是否可以删除背景颜色?
- java - 在运行时使用 ssl 证书在一个应用程序中进行多个 Secure As400 连接 - Java
- makefile - 如何为 Ocaml 项目生成正确的 makefile
- c++ - 在 C++ 中定义包含 TTF_Font 变量的向量时出现“未定义大小”错误
- java - 导航组件:在移动到片段 B 时部分显示片段 A
- jpa - QueryDSL 的最新状态是什么?
- node.js - 从同一个类nodejs调用函数
- android - FAILURE:构建失败并出现异常。- 科尔多瓦
- r - 比较两个向量时运行相同的函数时出错