美祺's profileEden of HexagonPhotosBlogListsMore ![]() | Help |
|
October 28 java.io中对于zip文件的访问刚又翻起了旧书<core jave>看了看,觉得里面的关于io的部分还是很经典的,同时也发现了java对于时下的rar文件流的支持有点弱,也许没有看到新的功能块吧,呵呵:)
有个列取zip文件中txt文件的小application很有意思,特此把source发商来看看:)对了,这个是用了最新的eclipse3.2+MyEclipse5.0+Visual Editor2.20左的哦,体验了一下,不错,而且有点.net的味道了,不过依旧是富人的消遣阿——狂占内存,大概要500M以上了,苦了以后的java开发人员了,尤其是搞本地和C/S的,呵呵:)
package com.local.work.io;
import java.awt.Dimension;
import java.awt.Rectangle; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import javax.swing.JComboBox;
import javax.swing.JFileChooser; import javax.swing.JFrame; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.JPanel; import javax.swing.JTextArea; import javax.swing.filechooser.FileFilter; public class ZipTest2 extends JFrame {
private static final long serialVersionUID = 1L;
private JPanel jContentPane = null;
private JMenuBar jJMenuBar = null;
private JMenu File = null;
private JMenuItem Open = null;
private JMenuItem Exit = null;
private JTextArea fileText = null;
private JComboBox fileList = null;
private String zipname = "";
// @jve:decl-index=0:
/**
* This is the default constructor */ public ZipTest2() { super(); initialize(); } /**
* This method initializes this * * @return void */ private void initialize() { this.setSize(398, 286); this.setContentPane(getJContentPane()); this.setJMenuBar(getJJMenuBar()); this.setTitle("JFrame"); } /**
* This method initializes jContentPane * * @return javax.swing.JPanel */ private JPanel getJContentPane() { if (jContentPane == null) { jContentPane = new JPanel(); jContentPane.setLayout(null); jContentPane.add(getFileList(), null); jContentPane.add(getFileText(), null); } return jContentPane; } /**
* This method initializes jJMenuBar * * @return javax.swing.JMenuBar */ private JMenuBar getJJMenuBar() { if (jJMenuBar == null) { jJMenuBar = new JMenuBar(); jJMenuBar.setPreferredSize(new Dimension(20, 30)); jJMenuBar.setName("File"); jJMenuBar.add(getFile()); } return jJMenuBar; } /**
* This method initializes File * * @return javax.swing.JMenu */ private JMenu getFile() { if (File == null) { File = new JMenu(); File.setName("File"); File.setText("File"); File.add(getOpen()); File.add(getExit()); } return File; } /**
* This method initializes Open * * @return javax.swing.JMenuItem */ private JMenuItem getOpen() { if (Open == null) { Open = new JMenuItem(); Open.setName("Open"); Open.setText("Open"); Open.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { System.out.println("actionPerformed()"); JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(new File(".")); chooser.setFileFilter(new FileFilter() { public boolean accept(java.io.File f) { return (f.getName().toLowerCase().endsWith(".zip") || f .isDirectory()); } public String getDescription() {
return "zip files"; } }); int r = chooser.showOpenDialog(ZipTest2.this); if (r == JFileChooser.APPROVE_OPTION) { zipname = chooser.getSelectedFile().getPath(); scanZipFile(); } } }); } return Open; } private void scanZipFile() {
fileList.removeAllItems(); try { ZipInputStream zin = new ZipInputStream( new FileInputStream(zipname)); ZipEntry entry; while ((entry = zin.getNextEntry()) != null) { fileList.addItem(entry.getName()); zin.closeEntry(); } zin.close(); } catch (IOException e) { e.printStackTrace(); } } /**
* This method initializes Exit * * @return javax.swing.JMenuItem */ private JMenuItem getExit() { if (Exit == null) { Exit = new JMenuItem(); Exit.setName("Exit"); Exit.setText("Exit"); Exit.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { System.out.println("actionPerformed()"); System.exit(0); } }); } return Exit; } /**
* This method initializes fileText * * @return javax.swing.JTextArea */ private JTextArea getFileText() { if (fileText == null) { fileText = new JTextArea(); fileText.setBounds(new Rectangle(12, 8, 255, 96)); } return fileText; } /**
* This method initializes fileList * * @return javax.swing.JComboBox */ private JComboBox getFileList() { if (fileList == null) { fileList = new JComboBox(); fileList.setBounds(new Rectangle(1, 131, 292, 27)); fileList.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { System.out.println("actionPerformed()"); try { ZipInputStream zin = new ZipInputStream( new FileInputStream(zipname)); ZipEntry entry; fileText.setText(""); while ((entry = zin.getNextEntry()) != null) { if (entry.getName().equals( fileList.getSelectedItem().toString())) { BufferedReader in = new BufferedReader( new InputStreamReader(zin)); String s; while ((s = in.readLine()) != null) fileText.append(s + "\n"); } zin.closeEntry(); } zin.close(); } catch (IOException ex) { ex.printStackTrace(); } } }); } return fileList; } } // @jve:decl-index=0:visual-constraint="296,24" October 17 Like a rock----Words and music by bob segerStood there boldly Sweatin in the sun Felt like a million Felt like number one The height of summer Id never felt that strong Like a rock I was eighteen Didnt have a care Working for peanuts Not a dime to spare But I was lean and Solid everywhere Like a rock My hands were steady My eyes were clear and bright My walk had purpose My steps were quick and light And I held firmly To what I felt was right Like a rock Like a rock, I was strong as I could be Like a rock, nothin ever got to me Like a rock, I was something to see Like a rock And I stood arrow straight Unencumbered by the weight Of all these hustlers and their schemes I stood proud, I stood tall High above it all I still believed in my dreams Twenty years now Whered they go? Twenty years I dont know Sit and I wonder sometimes Where theyve gone And sometimes late at night When Im bathed in the firelight The moon comes callin a ghostly white And I recall Recall Like a rock. standin arrow straight Like a rock, chargin from the gate Like a rock, carryin the weight Like a rock Lihe a rock, the sun upon my skin Like a rock, hard against the wind Like a rock, I see myself again Like a rock October 16 Need some Java?People always written down what they feel to must write down, and that's the reason for me to not have
continue with my new mood dairy:)
it's been nearly a month since the last time i wrote such dairy, and during the month, I'd be busy with
the new project for a foreign export company with their mobile storage management system, which is also a
kind of e-bussiness, some of u called it web, but i call it web service or web application:)(just some
terms). As for the begging of my second project, also my first project in .Net Framework( techs from
Microsoft Development), I felt a bit worried whether my limitted knowledge in .Net framwork could enable
me to finish those task in time with good quality. Luckily, the project manager had given me enough time
to get familiar with the developing style in .Net framework and assigned another experienced programmer
to cooperate in this project, while he's writting about the layer of bussiness, data models and data
accessing, me with the UI funtion. I had to admitted that the manager is so kind and far-sight, cause he
let me do the UI part, which is a fastest way to know better with .Net framework and it's charactors for
such a freshman like me.
Till now, I can finish most part of the project and sometimes I wrote the parts of the other partner's
duty, cause I'm good at the demands and it's better for me to operate the bussiness part. It's exciting
for me to get through the first difficulty and there is still a long way for me to deploy in the world of
the framework of god dammit Microsoft world!!!( I do love Java or any other language but the .net
framework, cause those junk from Micorsoft would make all the programmers blunter and bluner!
Need some Java, hum?:) October 14 System类中有关系统变量的一些常量参数System类中有关系统变量的一些常量参数, 如user.dir(当前工程文件夹),user.country,user.home等,还好System里有个getProperties的方法返回一个带有hashtable的Property类,可以看到所有的系统变量,特此列表如下:
-- listing properties --
java.runtime.name=Java(TM) 2 Runtime Environment, Stand... sun.boot.library.path=D:\Winserver\Program Files\jdk1.6.0\j... java.vm.version=1.6.0-rc-b66 java.vm.vendor=Sun Microsystems Inc. java.vendor.url=http://java.sun.com/ path.separator=; java.vm.name=Java HotSpot(TM) Client VM file.encoding.pkg=sun.io user.country=CN sun.os.patch.level=Service Pack 2 java.vm.specification.name=Java Virtual Machine Specification user.dir=E:\MyJavaWorks\workspace\JavaNetWorkTest java.runtime.version=1.6.0-rc-b66 java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment java.endorsed.dirs=D:\Winserver\Program Files\jdk1.6.0\j... os.arch=x86 java.io.tmpdir=C:\DOCUME~1\JEWEL\LOCALS~1\Temp\ line.separator= java.vm.specification.vendor=Sun Microsystems Inc. user.variant= os.name=Windows XP sun.jnu.encoding=GBK java.library.path=D:\Winserver\Program Files\jdk1.6.0\b... java.specification.name=Java Platform API Specification java.class.version=50.0 sun.management.compiler=HotSpot Client Compiler os.version=5.1 user.home=C:\Documents and Settings\JEWEL user.timezone= java.awt.printerjob=sun.awt.windows.WPrinterJob file.encoding=GBK java.specification.version=1.6 user.name=JEWEL java.class.path=E:\MyJavaWorks\workspace\JavaNetWorkT... java.vm.specification.version=1.0 sun.arch.data.model=32 java.home=D:\Winserver\Program Files\jdk1.6.0\jre java.specification.vendor=Sun Microsystems Inc. user.language=zh awt.toolkit=sun.awt.windows.WToolkit java.vm.info=mixed mode java.version=1.6.0-rc java.ext.dirs=D:\Winserver\Program Files\jdk1.6.0\j... sun.boot.class.path=D:\Winserver\Program Files\jdk1.6.0\j... java.vendor=Sun Microsystems Inc. file.separator=\ java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport... sun.cpu.endian=little sun.io.unicode.encoding=UnicodeLittle sun.desktop=windows sun.cpu.isalist=pentium_pro+mmx pentium_pro pentium+m... 相信——孙燕姿相信
突然觉得我只是一个人 有点孤单浅浅的忧郁 我不知道明天会不会很美丽 虽然今天天很蓝 而云很白 风很凉 今天日记空白没有关系 不必每件事情都在意 不想工作 不想困扰自己 不必刻意想你 该是我的总会来 就算挑战 我不走开 一点点你的微笑 已经让我觉得温暖 我还不懂坚持 正好让我 学会去爱 我曾经看见困难 变得胆小 不够勇敢 但还是要相信 相信感觉 相信简单 有一天 等我懂得事实也许更会幸福 至少现在让我去相信 哦 我还是会相信 相信感觉 相信简单 NBA十大PK高手!!!-- [转帖]NBA十大PK高手!!!
10、大鲨鱼奥尼尔
大鲨鱼同学其实是个比较好说话的人,不擅长打架,心地善良,又很有幽默感。还很有正义感(去落杉基警察局当了回警察)可是他一脸的凶相总让人怀疑他不是什么好人。鲨鱼在最近几年有趣的事儿主要是俩,一个是被奥克利掐了转身抡胳膊去打布拉德.米勒(连仇人是谁都分不清是谁还打架),一个是被巴克利按地上扁。其实他打架的战绩并不佳基本都是挨打的。当初如果不是别人拦着,奥克利和米勒要上去打他,他绝对就是条死鱼了。被巴克利打就更不用说了,被矮了他近20公分的巴克利(两人块头倒是差不多)按在底上痛扁连还手的机会都没有那是惨啊!!!他块头是大,但是拳头挥出去以后基本上打不到人。他打架是属于那种效果极差(基本挨打)但是场面很热闹好玩的。
9、斯普雷维尔
前金州勇士队主帅卡列西莫至今一看到斯普雷维尔,都会全身发抖,97年普雷维尔的一招“锁喉手”险些要了他的老命。之后,斯普雷维尔被禁赛长达68场,并因此而损失了640万美元。这个记录保持了8年之久。直到去年的奥本山打架事件以后,阿泰斯特才打破了他的记录。02年斯普雷维尔在一艘游艇上因为女人与一名男子打架受伤,还受到尼克斯队的警告外加罚款。03年在森林狼与猛龙的一场比赛中因为猛龙前锋暗算加内特,斯普雷维尔冲上前狠狠的教训了对方,领回一个技术犯规。
8“怒吼天尊”拉希德?华莱士
NBA出了名的暴力分子,NBA的技术犯规王。当年一次对勇士的比赛,因一块飞来的口香糖他就曾跑到场边追打一名勇士球迷。之后,越来越多的球员和球迷加入了混战之中,但迅速被赶到的警察所制止。在开拓者的时候他将技术犯规发挥到了极限,只要他一觉得裁判的判罚不合理就直冲裁判而去对着裁判吹胡子瞪眼的,还时不时拿自己满脸的胡子去扎裁判,好像要掐断他的脖子,那么裁判不得不给他一个技术犯规。后到了活塞后有所收敛。但他还是无法控制他自己的脾气。05年4月27日对阵76人的时候他领到了个人职业生涯第228次技术犯规,为他声名狼藉的职业生涯又添上了重重一笔,当时华莱士因对一次判罚不满,扯掉球衣挥动双拳准备暴打裁判,结果吃到了技术犯规。 可奇怪的是每次他领到技术犯规后他的表现总是非常出现,是不是只有技术犯规才能激起他的斗志呢。
7、阿郎索.莫宁
90年代身材最矮小的中锋 ,混了一辈子的内线,脾气十分暴躁,眼神野气十足,充满霸气。可以说是见神杀神见鬼灭鬼。 知道现任火箭队主帅范?甘迪是什么时候开始出名的吗??他也许现在最害怕的人就是莫宁。1997年东部半决赛第五场,热队前锋PJ?布朗掀翻尼克斯的沃德,于是一场涉及十多人的大斗殴上演,莫宁冲在最前端一路杀进尼克斯内部。一年后的季后赛莫宁以一己之力挑战纽约黑帮,痛扁著名流氓老狗奥克利。如果不是范?甘迪奋不顾身抱住其腿,也许当年他就血洗纽约城了。这个画面至今还是NBA打架史最经典画面。可以说永留史册。03年在网队的时候因为看不惯马丁,对他在队里的领有位置不以为然两人又差点动起手来。如果没有尤因也许莫宁至今仍旧是一个打架积极分子。。“阿伦佐,冷静,你是打球的,不是打架的!”尤因的成熟和友情,是浇灭莫宁怒火的最大原因。
6、马龙
说起马龙就不得不说马龙的铁肘,和钢管一样结实有力,让不少人吃到苦头。这肘刚劲有力,大开大阖,属于刚猛一派。97年对马刺,马龙就轻轻的转个身结果海上将军晕倒后来经医院检查是轻微脑震荡。可以说没有几个人能吃得消马龙这一肘。96年季后赛西部决赛的时候奥尼尔放到了爵士的奥特斯塔格马龙走到鲨鱼前面说了句“有本事对我来”结果鲨鱼灰头灰脸的走开了,而且湖人被爵士杀了个4比0。最经典的还数和大虫,在场内打的不过隐一直打到角斗场,如果不是大虫带着保镖一起上,恐怕大虫就死的很难看了。而弥坚,是其过人之处。
--------------------------------------------------------------------------------
-- 作者:巴蒂尘埃 -- 发布时间:2005-10-7 18:02:00
--
5、阿泰斯特
他的偶像就是大虫罗德曼,现在大家明白他为什么要穿91号队服了吧。上赛季的奥本山打架事件让这小子一战成名,大有赶超罗德曼的迹象。看看他的绰号:野兽。就知道他有多猛了。奥本山打架事件也成为NBA历史上大家场面最轰动的了。而作为主角的阿泰斯特还把狂人维持了8年之久的禁赛记录给破了而且一下子提高到73场。相信大家对奥本山打架事件再熟悉不过了。我也不多废话了。
4、奥克利
著名的恶汉,当年的纽约黑帮的老大,手下有一大批著名打手,参加大小战役不计其数,除了有一次被叠罗汉压在底下伤了腿骨,还有97年被莫宁痛扁(还好教练爱徒如子)其余从未吃亏。纽约当年的钢铁防守,若无他,大猩猩也难以独吞篮下。在1994年总决赛中错位防守使大梦吃尽苦头。此人生来就是打架的料子,力量足,体重够,身材高,先天条件可称史上最佳。炮轰NBA官方,除了他我想没有几个人有胆量,在猛龙炮轰卡特老母,让卡特敢怒不敢言。奥克利还在火箭呆过和姚明还算是朋友,他们认识的方式很特别。姚明在新赛季对阵奇才,当时还是乔丹助手的奥克利曾经在比赛中领命防守姚明,结果让小巨人接二连三被撞到了好几次!回忆起这一幕,姚明还觉得很气愤,他说道:“他那哪里是打球啊,分明是去打架的。可这就是奥克利的打球方式。奥克利喜欢大打出手,打人从来不商量,为所欲为,十分嚣张。尤其他还常以正义的面目出现,迷惑众人,骗取支持。他和巴克利同名,都叫查尔斯,而两人也有个共同点:瞅着不顺眼,打!奥克利打人从来都是直来直去。
3。大虫罗德曼
也许你会奇怪为什么大虫只排在第三,但事实如此。大虫的招其实大多是阴招。上不得台面。一般是撕咬拧摸掐捏等诸般小招。在底特律的时候遇上兰比尔两人真是相逢恨晚,从此两人连手出战,狼狈为奸,未尝败绩,连飞人大帝都吃尽苦头。无论是谁只要跟底特律打球都得万分小心不能得罪了这位老胸。后来在费城遇到了终身对手巴克利。真是棋逢对手,将遇良才,知道一山更比一山高,“坏孩子军团”解散后后转投公牛队,乔丹不计前仇,罗德曼忠心为乔丹效劳。从此公牛的苦活累活他都包了,而且无怨无悔。最著名的战例就是在总决赛上和马龙摔交一直摔到场外可以说是前无古人。当时著名海报如下: 大虫戴墨镜,帽子,鼻环,耳环,做酷状。 字幕: 一周有七天 一天有二十四小时 我随时可以摆平卡尔 而且他的花边新闻更是NBA无人能及。他还有个绰号:花花太岁。
2、兰比尔
也许大家给这个名字很陌生,他可是大虫的师傅级人物啊。上世纪九十年代,两连冠时期的那支活塞队,是公认的“坏孩子军团”,比尔-兰比尔则是“坏孩子”中公认的头儿。队里除了微笑刺客托马斯就数他说话最有分量。他臭名昭著,胳膊肘的天才。善于主动发难,有极强的组织和煽动能力。有仇必报。曾经故意弄断己队王牌微笑刺客的腿。飞人和大鸟最忌惮的人物。最善于无故殴打他人。尤其喜欢殴打原费城的马洪(很奇怪,我看他们打架好几次,不知这俩人可有什么深仇大恨,不过后来还是让巴克利给修理了),他的小动作更是大虫的师傅。最著名的暗亏是总决赛中企图对天勾动手,天勾还以假摔。比尔可以烦得对手主动去找他打架,而那时他就会“乖乖”地装成一个“无辜者”,似乎所有的错都是对手一手造成的,而他是为了“自卫”才和别人拳脚相加。更夸张的是,兰比尔的演技极为精湛,迪瓦茨与他相比,也有如“小巫见大巫”。兰比尔会躺在地上装死,还会抱着篮架骗取裁判的“怜悯”,彻底激怒对手的同时,又骗得了裁判的同情,一石二鸟。很多球员都恨不得把兰比尔碎尸万段,费城76人老板就直言不讳称只要巴克利揍兰比尔,自己就愿意替巴克利缴纳罚款,不管交多少次罚款都无所谓。
1、巴克利
尔斯爵士是NBA最直性子的怪物和最天才的幽默演员。身高虽然不高,但是体重超人。和飞人大帝是死党。NBA古往今来中打架最厉害当属巴克力.刚入行就因为帮助J-博士殴打大鸟伯德而轰动一时。他当队友被人欺负时也会插一腿,“你去扇他一巴掌,我来交罚款。”在看到马洪遭兰比尔殴打时挺身而出直拳痛击兰比尔,营造著名大战“费城群殴”。罗德慢最怕的人就是巴克力,碰到巴克力,罗就规矩许多,小动作少了很多,垃圾话少了很多.1999年巴克力和奥胖单挑还有多少人记得.老巴把球砸到奥胖的头上,奥胖当然不会服气,一个老拳就打向巴克力,巴克力闪了过去,包起奥胖的大腿把奥胖掀翻在地。NBA历史上没有巴克利不敢打的人,当年76人对活塞,巴克利一个人面对活塞五名球员照样冲了上去,痛打了NBA的当时的霸王?活塞中锋兰比尔,痛快!巴克利打架从来没有吃过亏!从来只有他打别人,没有人敢打他! 巴克利是一个可以让你前一分钟笑,后一分钟哭的人。他只说他想说的、做他想做的,正确与否,或者合不合适他可是懒得去理会的。 作为大虫唯一惧怕者,向来敢做敢为,性情暴躁但是极有正义感,是NBA几个著名大坏蛋的克星。 October 12 关于.net数据操作功能类datahelper的研究最近接触了下datahelper类,发现其中有很多需要商榷的地方,我会陆续给出各个功能的解释和其他较好的方法,现列出该类如下 //==================================================================== // Copyright (C) 2005 BinaryIntellect Consulting. All rights reserved. // Visit us at www.binaryintellect.com //==================================================================== using System; using System.Collections.Generic; using System.Text; using System.Data; using System.Configuration; using System.Data.Common; using System.Data.SqlClient; using System.Data.OleDb; using System.Data.Odbc; using System.Data.OracleClient; using System.IO; namespace BinaryIntellect.DataAccess { public class DatabaseHelper:IDisposable { private string strConnectionString; private DbConnection objConnection; private DbCommand objCommand; private DbProviderFactory objFactory = null; private bool boolHandleErrors; private string strLastError; private bool boolLogError; private string strLogFile; public DatabaseHelper(string connectionstring,Providers provider) { strConnectionString = connectionstring; switch (provider) { case Providers.SqlServer: objFactory = SqlClientFactory.Instance; break; case Providers.OleDb: objFactory = OleDbFactory.Instance; break; case Providers.Oracle: objFactory = OracleClientFactory.Instance; break; case Providers.ODBC: objFactory = OdbcFactory.Instance; break; case Providers.ConfigDefined: string providername=ConfigurationManager.ConnectionStrings["connectionstring"].ProviderName; switch (providername) { case "System.Data.SqlClient": objFactory = SqlClientFactory.Instance; break; case "System.Data.OleDb": objFactory = OleDbFactory.Instance; break; case "System.Data.OracleClient": objFactory = OracleClientFactory.Instance; break; case "System.Data.Odbc": objFactory = OdbcFactory.Instance; break; } break; } objConnection = objFactory.CreateConnection(); objCommand = objFactory.CreateCommand(); objConnection.ConnectionString = strConnectionString; objCommand.Connection = objConnection; } public DatabaseHelper(Providers provider):this(ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString,provider) { } public DatabaseHelper(string connectionstring): this(connectionstring, Providers.SqlServer) { } public DatabaseHelper():this(ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString,Providers.ConfigDefined) { } public bool HandleErrors { get { return boolHandleErrors; } set { boolHandleErrors = value; } } public string LastError { get { return strLastError; } } public bool LogErrors { get { return boolLogError; } set { boolLogError=value; } } public string LogFile { get { return strLogFile; } set { strLogFile = value; } } public int AddParameter(string name,object value) { DbParameter p = objFactory.CreateParameter(); p.ParameterName = name; p.Value=value; return objCommand.Parameters.Add(p); } public int AddParameter(DbParameter parameter) { return objCommand.Parameters.Add(parameter); } public DbCommand Command { get { return objCommand; } } public void BeginTransaction() { if (objConnection.State == System.Data.ConnectionState.Closed) { objConnection.Open(); } objCommand.Transaction = objConnection.BeginTransaction(); } public void CommitTransaction() { objCommand.Transaction.Commit(); objConnection.Close(); } public void RollbackTransaction() { objCommand.Transaction.Rollback(); objConnection.Close(); } public int ExecuteNonQuery(string query) { return ExecuteNonQuery(query, CommandType.Text, ConnectionState.CloseOnExit); } public int ExecuteNonQuery(string query,CommandType commandtype) { return ExecuteNonQuery(query, commandtype, ConnectionState.CloseOnExit); } public int ExecuteNonQuery(string query,ConnectionState connectionstate) { return ExecuteNonQuery(query,CommandType.Text,connectionstate); } public int ExecuteNonQuery(string query,CommandType commandtype, ConnectionState connectionstate) { objCommand.CommandText = query; objCommand.CommandType = commandtype; int i=-1; try { if (objConnection.State == System.Data.ConnectionState.Closed) { objConnection.Open(); } i = objCommand.ExecuteNonQuery(); } catch (Exception ex) { HandleExceptions(ex); } finally { objCommand.Parameters.Clear(); if (connectionstate == ConnectionState.CloseOnExit) { objConnection.Close(); } } return i; } public object ExecuteScalar(string query) { return ExecuteScalar(query, CommandType.Text, ConnectionState.CloseOnExit); } public object ExecuteScalar(string query,CommandType commandtype) { return ExecuteScalar(query, commandtype, ConnectionState.CloseOnExit); } public object ExecuteScalar(string query, ConnectionState connectionstate) { return ExecuteScalar(query, CommandType.Text, connectionstate); } public object ExecuteScalar(string query,CommandType commandtype, ConnectionState connectionstate) { objCommand.CommandText = query; objCommand.CommandType = commandtype; object o = null; try { if (objConnection.State == System.Data.ConnectionState.Closed) { objConnection.Open(); } o = objCommand.ExecuteScalar(); } catch (Exception ex) { HandleExceptions(ex); } finally { objCommand.Parameters.Clear(); if (connectionstate == ConnectionState.CloseOnExit) { objConnection.Close(); } } return o; } public DbDataReader ExecuteReader(string query) { return ExecuteReader(query, CommandType.Text, ConnectionState.CloseOnExit); } public DbDataReader ExecuteReader(string query,CommandType commandtype) { return ExecuteReader(query, commandtype, ConnectionState.CloseOnExit); } public DbDataReader ExecuteReader(string query, ConnectionState connectionstate) { return ExecuteReader(query, CommandType.Text, connectionstate); } public DbDataReader ExecuteReader(string query,CommandType commandtype, ConnectionState connectionstate) { objCommand.CommandText = query; objCommand.CommandType = commandtype; DbDataReader reader=null; try { if (objConnection.State == System.Data.ConnectionState.Closed) { objConnection.Open(); } if (connectionstate == ConnectionState.CloseOnExit) { reader = objCommand.ExecuteReader(CommandBehavior.CloseConnection); } else { reader = objCommand.ExecuteReader(); } } catch (Exception ex) { HandleExceptions(ex); } finally { objCommand.Parameters.Clear(); } return reader; } public DataSet ExecuteDataSet(string query) { return ExecuteDataSet(query, CommandType.Text, ConnectionState.CloseOnExit); } public DataSet ExecuteDataSet(string query,CommandType commandtype) { return ExecuteDataSet(query, commandtype, ConnectionState.CloseOnExit); } public DataSet ExecuteDataSet(string query,ConnectionState connectionstate) { return ExecuteDataSet(query, CommandType.Text, connectionstate); } public DataSet ExecuteDataSet(string query,CommandType commandtype, ConnectionState connectionstate) { DbDataAdapter adapter = objFactory.CreateDataAdapter(); objCommand.CommandText = query; objCommand.CommandType = commandtype; adapter.SelectCommand = objCommand; DataSet ds = new DataSet(); try { adapter.Fill(ds); } catch (Exception ex) { HandleExceptions(ex); } finally { objCommand.Parameters.Clear(); if (connectionstate == ConnectionState.CloseOnExit) { if (objConnection.State == System.Data.ConnectionState.Open) { objConnection.Close(); } } } return ds; } private void HandleExceptions(Exception ex) { if (LogErrors) { WriteToLog(ex.Message); } if (HandleErrors) { strLastError = ex.Message; } else { throw ex; } } private void WriteToLog(string msg) { StreamWriter writer= File.AppendText(LogFile); writer.WriteLine(DateTime.Now.ToString() + " - " + msg); writer.Close(); } public void Dispose() { objConnection.Close(); objConnection.Dispose(); objCommand.Dispose(); } //Add by KOTS public DataTable GetSchema() { DataTable ret = null; try { if (objConnection.State == System.Data.ConnectionState.Closed) { objConnection.Open(); } ret = objConnection.GetSchema("Tables"); } catch (Exception ex) { HandleExceptions(ex); } finally { objConnection.Close(); } return ret; } } public enum Providers { SqlServer,OleDb,Oracle,ODBC,ConfigDefined } public enum ConnectionState { KeepOpen,CloseOnExit } } October 11 我亲爱的的姐姐我亲爱的的姐姐来自东北,来自齐齐哈尔,来自伟大的东北黑土地。
大学里认识姐姐的时候觉得她老哥们的,经常和我们寝室去后门打CS,呵呵要么就是喝酒。也会和我一起考虑一些棘手的问题。但是那段时光是最快乐的时光。
但是知道姐姐最近有了一些烦恼,虽然她总是闭口不谈,但是我总是想帮助她,所以这个也是我苦恼的地方,总不能老找乐子逗人吧,那样治标不治本:(
姐姐,你明白不? |
|
|