sqlCon=java.sql.DriverManager.getConnection("jdbc:mysql://"+ipaddress+"/vm?user=user1&password=user1&useUn)

解决方案 »

  1.   

    怎样读取文件中一行内容(ip地址),付给一个变量ipaddress ,然后连数据库时只写这个变量
      

  2.   

    import java.io.*;BufferedReader reader =
              new BufferedReader(new FileReader(new File("c:\\filename.txt")));
    String ipaddress= reader.readLine();
      

  3.   

    <%
        String Pathstr=getServletContext().getRealPath("");
        FileInputStream tfile=new FileInputStream(Pathstr+"\\conndb.txt");
        String str="";
        int c;
        while ((c=tfile.read())!=-1)
        {
      str=str+(char)c;
        }
         int first=str.indexOf(":");
         int last=str.lastIndexOf(":");
         int lenth=str.length();
         String First=str.substring(0,first);
         String Next=str.substring(first+1,last);
         String Last=str.substring(last+1,lenth);
         tfile.close();
    %>
      

  4.   

    String userip=request.getRemoteAddr();
    out.print(Userip + "&nbsp;" + Userreq);
    OK!!!!!