从原则上来说,对同一数据库类型来说,高版本的数据库的jar应该是可以正常访问低版本的数据库的。所以没有必要因为这个而分成两个工程。你只要在工作中使用高版本的jar就可以了。
如果你的两个数据库是不同类型的话,那么数据库访问的jar也就不一样,使用的类也不会相同。
那也就没有必要分成两个工程。
如果确实需要分成两个工程的话,那可以考虑用一个工程将结果输出到文件中,另外一个工程将结果从文件中读取。当然,因为文件的打开关闭 *** 作会比较慢,所以可能需要设置一个固定的时间点进行一次写入之后再关闭文件。
另外你说的servlet是什么意思?是你的两个工程其实都是web工程吗?
如果是web工程的话,那其实两个工程确实可以无缝 *** 作。因为对web工程来说,所有访问都是提交一个url,并将参数一起提交。
像你这种情况,你可以在A工程的action中将结果取得之后post到B工程的插入数据库 *** 作的action中去,然后在那个action中进行数据库的插入 *** 作。
上面这些都是理论,至于如果说要代码的话,那很抱歉,实在没有时间也没有精力去写额。毕竟对你的具体情况不了解,如果你不懂上面说的,那给你写了也没用。如果你理解了的话,那相信你花点时间自己也能写出来了。
前段时间正好做了,导入和导出的,你自己看吧
/导出数据为XLS格式
@param fos
@param bo
/
public void writeExcelBo(FileOutputStream fos, javautilVector ve)
{
jxlwriteWritableWorkbook wwb;
try
{
wwb= WorkbookcreateWorkbook(fos);
jxlwriteWritableSheet ws= wwbcreateSheet("booksheet", 10);
wsaddCell(new jxlwriteLabel(0, 1, "书目ID"));
wsaddCell(new jxlwriteLabel(1, 1, "ISBN"));
wsaddCell(new jxlwriteLabel(2, 1, "定价"));
wsaddCell(new jxlwriteLabel(3, 1, "书名"));
wsaddCell(new jxlwriteLabel(4, 1, "原书名"));
wsaddCell(new jxlwriteLabel(5, 1, "副题名"));
wsaddCell(new jxlwriteLabel(6, 1, "著者"));
wsaddCell(new jxlwriteLabel(7, 1, "译者"));
wsaddCell(new jxlwriteLabel(8, 1, "版次"));
wsaddCell(new jxlwriteLabel(9, 1, "出版地"));
wsaddCell(new jxlwriteLabel(10, 1, "出版社"));
wsaddCell(new jxlwriteLabel(11, 1, "出版日期"));
wsaddCell(new jxlwriteLabel(12, 1, "页数"));
wsaddCell(new jxlwriteLabel(13, 1, "书高"));
wsaddCell(new jxlwriteLabel(14, 1, "装帧"));
wsaddCell(new jxlwriteLabel(15, 1, "丛书名"));
wsaddCell(new jxlwriteLabel(16, 1, "一般性附注项"));
wsaddCell(new jxlwriteLabel(17, 1, "简介"));
wsaddCell(new jxlwriteLabel(18, 1, "主题词"));
wsaddCell(new jxlwriteLabel(19, 1, "中图法分类"));
wsaddCell(new jxlwriteLabel(20, 1, "更新日期"));
wsaddCell(new jxlwriteLabel(21, 1, "本数"));
book=new Book[vesize()];
for (int i= 0; i < vesize(); i++)
{
book[i]= (Book)veget(i);
wsaddCell(new jxlwriteLabel(0, i + 2, "" + book[i]getBookId()));
wsaddCell(new jxlwriteLabel(1, i + 2, book[i]getIsbn()));
wsaddCell(new jxlwriteLabel(2, i + 2, "" + book[i]getPrice()));
wsaddCell(new jxlwriteLabel(3, i + 2, book[i]getBookTitle()));
wsaddCell(new jxlwriteLabel(4, i + 2, book[i]getOldFilename()));
wsaddCell(new jxlwriteLabel(5, i + 2, book[i]getSubTitle()));
wsaddCell(new jxlwriteLabel(6, i + 2, book[i]getWriter()));
wsaddCell(new jxlwriteLabel(7, i + 2, book[i]getTranscribe()));
wsaddCell(new jxlwriteLabel(8, i + 2, "" + book[i]getVersion()));
wsaddCell(new jxlwriteLabel(9, i + 2, book[i]getPublishCity()));
wsaddCell(new jxlwriteLabel(10, i + 2, book[i]getPublisher()));
wsaddCell(new jxlwriteLabel(11, i + 2, book[i]getPublishDate()toString()));
wsaddCell(new jxlwriteLabel(12, i + 2, "" + book[i]getPage()));
wsaddCell(new jxlwriteLabel(13, i + 2, "" + book[i]getHight()));
wsaddCell(new jxlwriteLabel(14, i + 2, book[i]getInstall()));
wsaddCell(new jxlwriteLabel(15, i + 2, book[i]getSeries()));
wsaddCell(new jxlwriteLabel(16, i + 2, book[i]getNotes()));
wsaddCell(new jxlwriteLabel(17, i + 2, book[i]getPrecisnotes()));
wsaddCell(new jxlwriteLabel(18, i + 2, book[i]getSubject()));
wsaddCell(new jxlwriteLabel(19, i + 2, book[i]getCls()replaceAll("_", "")));
wsaddCell(new jxlwriteLabel(20, i + 2, book[i]getUpdatedate()toString()));
wsaddCell(new jxlwriteLabel(21, i + 2, "0"));
}
jxlwriteWritableFont wfc=
new jxlwriteWritableFont(
WritableFontARIAL,
255,
WritableFontBOLD,
false,
UnderlineStyleNO_UNDERLINE,
jxlformatColourBLACK);
jxlwriteWritableCellFormat wcfFC= new jxlwriteWritableCellFormat(wfc);
wsaddCell(new jxlwriteLabel(0, 0, "为保证您提交定单的稳定和正确,导入定单时候请勿更改此表格式(请勿更改书目ID,订购本数自行添加!)"));
wwbwrite();
//关闭Excel工作薄对象
wwbclose();
} catch (IOException e)
{} catch (RowsExceededException e)
{} catch (WriteException e)
{}
}
//导入EXCEL
if (fgetName()indexOf("xls") > 0)
{
try
{
fis= new FileInputStream(f);
BookBean bob= new BookBean();
UserBean usb= new UserBean();
jxlWorkbook rwb= WorkbookgetWorkbook(fis);
jxlSheet sh= rwbgetSheet(0);
int rowCount= shgetRows();
SimpleDateFormat sdf= new SimpleDateFormat("dd/MM/yyyy");
book= new Book[rowCount - 1];
for (int i= 1; i < rowCount; i++)
{
book[i - 1]= new Book();
jxlCell[] ce= shgetRow(i);
book[i - 1]setIsbn(ce[0]getContents()toString());
book[i - 1]setSeries(ce[1]getContents()toString());
book[i - 1]setBookTitle(ce[2]getContents()toString());
book[i - 1]setWriter(ce[3]getContents()toString());
book[i - 1]setTranscribe(ce[4]getContents()toString());
book[i - 1]setPublisher(ce[5]getContents()toString());
book[i - 1]setPublishDate(sdfparse(ce[6]getContents()toString(), new ParsePosition(0)));
book[i-1]setVersion(IntegerparseInt(ce[7]getContents()toString()));
book[i-1]setPage(IntegerparseInt(ce[8]getContents()toString()));
book[i-1]setCls(ce[9]getContents()toString());
book[i-1]setPrecisnotes(ce[10]getContents()toString());
book[i-1]setInstall(ce[11]getContents()toString());
book[i-1]setPrice(FloatparseFloat(ce[12]getContents()toString()));
book[i-1]setUserid(usbgetUser()getUserid());
getVector()addElement(book[i - 1]);
}
rwbclose();
fisclose();
} catch (FileNotFoundException e)
{} catch (BiffException e)
{} catch (IOException e)
{} catch (NumberFormatException e)
{
ShowMessage("数据导入失败,请按照本软件要求的EXCEL格式导入定单");
}
}
以上就是关于在java里,我想写两个工程,一个工程读取数据库数据,另一个工程插入到其他数据库,怎么在两个工程间传递全部的内容,包括:在java里,我想写两个工程,一个工程读取数据库数据,另一个工程插入到其他数据库,怎么在两个工程间传递、java中把SQL数据库中的表导出到excel中.怎么实现、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)