我以前在连接MySql数据库的时候,没次开机后连接数据库时就会出现这种情况,我重启数据库就没事啦,别人的机子和我装的东西一样就没出现过此情况,不是什么大问题。是这段代码的问题么?

解决方案 »

  1.   

    晕,没有见过InputStreamReader(URL url) 构造函数的(还没用过jdk5.0 ,惭愧..),只好自己建了一个!
    import java.io.*;
    import java.net.URL;public class Test {public static void main(String[] args) throws Exception
    { BufferedReader file = new BufferedReader (new InputStreamReader(new URL("http://www.google.com/").openStream())); 
    String line; 
    while((line = file.readLine()) != null) 

    System.out.println(line); 

    }
    }再我这边运行良好,得到如下:
    F:\>java Test
    <html><head><meta http-equiv="content-type" content="text/html; charset=GB2312">
    <title>Google</title><style><!--
    body,td,a,p,.h{font-family:;}
    .h{font-size: 20px;}
    .q{color:#0000cc;}
    //-->
    </style>
    <script>
    <!--
    function sf(){document.f.q.focus();}
    // -->
    </script>
    </head><body bgcolor=#ffffff text=#000000 link=#0000cc vlink=#551a8b alink=#ff00
    00 onLoad=sf() topmargin=3 marginheight=3><center><table border=0 cellspacing=0
    cellpadding=0 width=100%><tr><td align=right nowrap><font size=-1><a href="/url?
    sa=p&pref=ig&pval=2&q=http://www.google.com/ig%3Fhl%3Dzh-CN">个性化主页</a>&nbsp
    ;|&nbsp;<a href="https://www.google.com/accounts/Login?continue=http://www.googl
    (以下省略..)
    ... ...
    ... ...我觉得可能是你网络的问题.并非程序.
      

  2.   

    Connection reset中文翻译过来就是连接重置