将记录插入Access DB的Java问题 [英] Java problem inserting a record into Access DB

查看:96
本文介绍了将记录插入Access DB的Java问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的人我在这里需要一个小的指导/帮助。我有一个读取txt文件的程序。这个txt文件包含格式的行


2007年1月3日,85.8


现在每行txt文件都要读入我的java程序然后插入(从程序进入Access数据库)。我不确定问题出在哪里。我知道它与我如何解析文件有关,或者我如何将我的参数传递给我的insertRecord()。


好​​的聊天,这是我需要帮助的代码。


这是读取文件的功能。

Alright folks I am in need of a lil guidance/assistance here. I have a program which reads in a txt file. This txt file contains lines of the form

January 3, 2007, 85.8

Now each line of the txt file is to be read into my java program and then inserted (from the program into an Access Database). I am not exactly sure of where the problem lies. I know it has something to do with how I am parsing the file, or how I am passing my arguments to my insertRecord().

Ok enough chatter, here is the code I need help with.

This is the function reading the file obviously.

展开 | 选择 < span class =codeDivider> | Wrap | 行号

推荐答案

ok我很确定我的代码中的所有内容都可以,因为无论如何,我可以告诉你。它的nullPointerExceptin导致我快速失去头发!
ok I am pretty sure everything is ok in my code, as far as I can tell anyway. Its this nullPointerExceptin that is causing me to lose hair at a rapid rate!



ok我很确定我的代码中的一切正常,据我所知。它的nullPointerExceptin导致我快速失去头发!
ok I am pretty sure everything is ok in my code, as far as I can tell anyway. Its this nullPointerExceptin that is causing me to lose hair at a rapid rate!



1.)不要使用StringTokenizer,而是使用String.split方法。

2.)在你的catch块中,不要打印Exception'的toString,而是调用execption.printStackTrace()。这样你就可以获得有关异常的完整信息。

3.)你的commitChanges()方法做什么?

1.) Don''t use StringTokenizer, use the String.split method instead.
2.) In your catch block, don''t print the Exception''s toString, call execption.printStackTrace() instead. That way you get full information about the exception.
3.) What does your commitChanges() method do?



1.)不要使用StringTokenizer,而是使用String.split方法。

2.)在你的catch块中,不要打印Exception'的toString,调用execption.printStackTrace()代替。这样你就可以获得有关异常的完整信息。

3.)你的commitChanges()方法有什么作用?
1.) Don''t use StringTokenizer, use the String.split method instead.
2.) In your catch block, don''t print the Exception''s toString, call execption.printStackTrace() instead. That way you get full information about the exception.
3.) What does your commitChanges() method do?



你的回复,我会在今晚尝试你的建议。我的commitchanges()方法只是将更改提交到数据库。没有它,记录就不会保存到数据库中。

ty for your reply, I will try your recommendations tonight. My commitchanges() method just commits the changes to the database. Without it the records won''t save to the database.


这篇关于将记录插入Access DB的Java问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆