📄 javaapplet_22.html
字号:
<p>5)关闭数据库连接</p> <p>public void closeConnection()<br> {<br> try{<br> theConnection.close ();<br> }<br> catch(Exception e)<br> {<br> handleException(e);<br> }<br> }<br> 当用户访问完某个数据库时,应该关闭数据库连接,释放与连接有关的资源。用户创建 的任何打开的ResultSet或者Statement对象将 自动关闭。另外,在关闭连接时可能发 生一个SQLException,也放到后面处理。</p> <p>6)处理异常和错误</p> <p>public void handleException(Exception e)<br> {<br> theStatus.setText("Error:"+e.getMessage ());<br> e.printStackTrace ();<br> if(e instanceof SQLException)<br> {<br> while((e=((SQLException)e).getNextException ())!=null)<br> {<br> System.out.println(e);<br> }<br> }<br> }<br> handleException()方法用来处理以上的错误和异常。该方法设置状态TextField包含与 异常有关的错误消息,使用getMessage()方法获得该消息。它还可以在System.out打印 堆栈轨迹。 </p> <p>三 安装ODBC数据源</p> <p>为了运行这个应用程序,用户必须 首先创建一个与MyTable数据库相对应的 ODBC数据源。 为了通过ODBC使用Access,用户必须安装Access Odbc驱动程序。如果用户没有安装该驱动 程序,那么还是先安装吧,什么,不会,不会也不行了,找一本书好好看看吧,这是肯定要 看的。我这儿简单的给你说一下吧:</p> <p>1.从控制面板中选择ODBC-32,双击(要是没有这个图标,那我真的没有办法了,它在安装 数据库的时候,应该会安装上的,否则就只能找一张数据库系统的安装盘,找到ODBC驱动程 序进行安装)。</p> <p>2.单击添加,选择Microsoft Access Driver。(如果这个图标也没有,那么你的机器是严 重缺乏营养,赶紧装数据库必须的软件,先装Access,这儿要用)</p> <p>3.输入你要使用的数据源的名称(如果没有,那就得先创建,我这儿就不说Access的使用方 法了)。描述就随便你了。</p> <p>4.单击选择按钮选择你已经创建好了的Access数据库的文件。</p> <p>5.点确定就可以了。如果你想为你数据库保密的话,可以加上用户名和密码。(在高级选项里面)。</p> <p> 要说明一点的是,如果你用VJ++编辑的此程序,要是运行不了,那就是数据库的连接没有设 置好,怎么将数据库设计好,以后再说吧。另外,VJ++有它自己的数据库驱动程序。很适合与 VJ++一起使用,可惜介绍这方面的书好象不是很多。</p> <p></p> </font></span> <!-- #EndEditable --> <br> </td> </tr> </tbody> </table> <table align=center border=0 cellpadding=0 cellspacing=0 width=540> <tbody> <tr> <td colspan="3"> <div align="right"> <!-- #BeginEditable "%D0%C5%CF%A2%D4%B4" --><font color="#666666"> (<a href="http://www.pconline.com.cn/" target="_blank">太平洋电脑信息网</a>) yy435/文 </font><!-- #EndEditable --></div> </td> </tr> </tbody> </table> <br> <br> <table align=center border=0 cellpadding=0 cellspacing=0 width=540> <tbody> <tr> <td colspan="3"> <div align="center"><font color="#666666"><img src="/zh_cn/images/more.gif" width="16" height="16"><!-SSE ELECT SSE-> <img src="/zh_cn/images/enterbbs.gif" width="19" height="17"><a href="/zh_cn/bbs/index.html" target="_blank">进入BBS</a> <img src="/zh_cn/images/enterchat.gif" width="19" height="19"><a href="/zh_cn/chat/index.html" target="_blank">进入聊天室</a> <img src="/zh_cn/images/close.gif" width="19" height="19"><a href="javascript:window.close();">关闭窗口</a><br> <!-SSE END SSE-></font></div> </td> </tr> </tbody> </table> <p> </p> <table class=large align=center border=0 cellpadding=0 cellspacing=0 width=550> <tbody> <tr> <td colspan="3"> </td> </tr> <tr> <td bgcolor=#dddddd colspan=3><b><font color=#000000><span class="text">﹣</span>更多本栏目内容</font></b></td> </tr> <tr bgcolor="#F6F6F6"> <td colspan=3>
<FONT COLOR="#02029E">☉<a href='/zh_cn/netschool/os/windows2000/575/20010226/122520.html' target='_blank'>Win2K和NT 4.0的协同作战</a> <br>
<FONT COLOR="#02029E">☉<a href='/zh_cn/netschool/homepage/dreamweaver/602/20010214/106825.html' target='_blank'>Dreamweaver4字体设置不能保存之BUG解决方案</a> <br>
<FONT COLOR="#02029E">☉<a href='/zh_cn/netschool/homepage/flash/603/20010226/126100.html' target='_blank'>Flash贺卡做起来</a> <br>
<FONT COLOR="#02029E">☉<a href='/zh_cn/netschool/softwares/system/621/20010212/109494.html' target='_blank'>GDISK全自动硬盘分区及格式化</a> <br>
<FONT COLOR="#02029E">☉<a href='/zh_cn/netschool/softwares/net/622/20010308/136452.html' target='_blank'>实战NETMEETING</a> <br>
<FONT COLOR="#02029E">☉<a href='/zh_cn/netschool/homepage/skill/605/20010219/118890.html' target='_blank'>主页用色的搭配艺术</a> <br>
<FONT COLOR="#02029E">☉<a href='/zh_cn/netschool/multimedia/photoshop/666/20010213/113201.html' target='_blank'>全新的图像处理体验--PHOTOSHOP 6.0</a> <br>
<FONT COLOR="#02029E">☉<a href='/zh_cn/netschool/net/netsafe/683/20010308/136411.html' target='_blank'>个人防火墙堵住VPN安全漏洞</a> <br>
<FONT COLOR="#02029E">☉<a href='/zh_cn/netschool/net/experience/684/20010219/118898.html' target='_blank'>网络隐私埋名大法</a> <br>
<FONT COLOR="#02029E">☉<a href='/zh_cn/netschool/security/kill/708/20010222/122477.html' target='_blank'>在线聊天当心“萨利姆”宏病毒</a> <br>
</td> </tr> </tbody> </table> </td> <td width="155" height="212" align="center" valign="top" bgcolor="FFF3E0"> <br> <table width="140" border="1" cellspacing="2" cellpadding="0" bordercolor="#626BDF" height="25" align="center"> <tr bgcolor="#626BDF"> <td> <div align="center"><font color="#FFFFFF"><span class=big><b>本站检索</b></span></font></div> </td> </tr> </table> <div align="center"> <form method="post" action="http://app0.china.com/editor/search2.php" target="_blank"> <p> <font size=2> <input type="text" size=15 name="textfield"> <br> 与 <input CHECKED name=andor type=radio value=and> 或 <input name=andor type=radio value=or> <select name="xwss"> <option value=1>标题</option> <option value=3>全文</option> <option value=2>关键字</option> <option value=4>以上全部</option> </select> <input type="submit" name="Submit" value="搜索"> <br> </font> </form> </div> <table width="141" border="1" cellspacing="2" cellpadding="0" bordercolor="#626BDF" height="25" align="center"> <tr bgcolor="#626BDF"> <td> <div align="center"><span class=big><b><font color="#FFFFFF">中华网推荐</font></b></span></div> </td> </tr> </table> <div align="center"><br> <table align=center border=0 cellpadding=0 cellspacing=0 width=145 height="134">
<tbody>
<tr valign="top">
<td height="364">
<p>
<span class=text> <li><a href="http://news.china.com/zh_cn/focus/meeting/">关注两会 关注未来</a></li><br>
<li><a href="http://news.china.com/zh_cn/hot/cartoon/index.html">中华网每日时事漫画</a></li><br>
<li><a href="http://finance.china.com/zh_cn/hot/hot20011/">B股淘金实战指南
</a></li> <br>
<li><a href="http://news.china.com/zh_cn/focus/japan/">全面审视中日关系</a></li><br>
<li><a href="http://sports.china.com/zh_cn/focus/olympic/">北京申办奥运会特辑
</a></li>
<br>
<li><a href="http://military.china.com/zh_cn/enginery/index1.html">现代兵器网上杂志</a></li>
<br>
<li><a href="http://fun.china.com/zh_cn/subject/wohucanglong/index.html">《卧虎藏龙》与奥斯卡</a></li>
<br>
<li><a href="http://game.china.com/zh_cn/hotspot/gulong/index.html" >《古龙群侠传》专题</a></li><br>
<li><a href="http://edu.china.com/zh_cn/news/qiuzhi/index.html">大学生求职经典秘籍</a></li><br>
<li><a href="http://travel.china.com/zh_cn/special/tanxian/">新世纪探险之旅</a></li><br>
<li><a href="http://netbar.china.com">全国网吧登录超8000家</a></li>
<br>
<li><a href="http://www.china.com/zh_cn/women/">中国妇女报中华网调查</a></li>
<br>
<li><a href="http://holiday.china.com/">三八妇女节关爱女性</a></li>
</span> </td>
</tr>
</tbody>
</table>
<br> <script language=javascript> var plugNum = Math.random()+1; document.writeln('<IFRAME SRC="http://ad1.china.com/cgi-bin/ssirand.cgi/'+plugNum+'?CAMPAIGN=tech1" width="117" height="37" SCROLLING=no FRAMEBORDER=0 MARGINWIDTH="0" MARGINHEIGHT="0">'); document.writeln('<NOFRAME>'); document.writeln('<a href="http://ad1.china.com/cgi-bin/redirect.cgi/'+plugNum+'" target="_blank"><img src="http://ad1.china.com/cgi-bin/getimage.cgi/'+plugNum+'?CAMPAIGN=tech1" width="117" height="37" border="0" alt="Served by China.com"></a>'); document.writeln('</NOFRAME>'); document.writeln('</IFRAME>'); </script> <br> <br> <script language=javascript> var plugNum = Math.random()+1; document.writeln('<IFRAME SRC="http://ad1.china.com/cgi-bin/ssirand.cgi/'+plugNum+'?CAMPAIGN=tech2" width="117" height="37" SCROLLING=no FRAMEBORDER=0 MARGINWIDTH="0" MARGINHEIGHT="0">'); document.writeln('<NOFRAME>'); document.writeln('<a href="http://ad1.china.com/cgi-bin/redirect.cgi/'+plugNum+'" target="_blank"><img src="http://ad1.china.com/cgi-bin/getimage.cgi/'+plugNum+'?CAMPAIGN=tech2" width="117" height="37" border="0" alt="Served by China.com"></a>'); document.writeln('</NOFRAME>'); document.writeln('</IFRAME>'); </script> </div> </td> </tr></table><table width="755" border="0" cellspacing="0" cellpadding="0" align="center"> <tr> <td width="600" valign="top"> </td> <td width="155" bgcolor="FFF3E0"> </td> </tr></table><hr width="755"><table width="755" border="0" cellspacing="0" cellpadding="0" align="center"> <tr> <td height="15"> <div align="center"><a href="mailto:netschool@sz.china.com" class="text">网络教室编辑信箱</a></div> </td> </tr></table><table align=center cellpadding=12 width=601> <tbody> <tr valign=top> <td colspan=3 height="2" class="text"> <div align="center"><a href="http://chinese.china.com/zh_cn/general/bqsm.html">版权声明</a> | <a href="http://chinese.china.com/zh_cn/general/contact.html">联系方法</a> | <a href="http://chinese.china.com/zh_cn/general/advert.html">刊登广告</a> | <a href="http://chinese.china.com/zh_cn/general/help.html">使用说明</a> | <a href="http://chinese.china.com/zh_cn/general/aboutchina.html">关于中华网</a> | <a href="http://chinese.china.com/zh_cn/general/legal.html">豁免条款</a> <br> </div> <table width="189" border="0" cellspacing="3" cellpadding="3" align="center"> <tr valign="middle"> <td> <div align="center"><span class="text">版权所有 中华网 <a href="http://www.china.com"><img src="/zh_cn/etc/images/chinacom_logo.gif" width="62" height="14" border="0" alt="china.com"></a></span> </div> </td> </tr> </table> </td> </tr> </tbody> </table> </body><!-- #EndTemplate --></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -