首页上一页 1 下一页尾页 3 条记录 1/1页
《JSP程序开发范例宝典》第8章的问题(问题二)
发表在JavaWeb图书答疑
2008-04-16
是否精华
是
否
版块置顶:
是
否
<P>《JSP程序开发范例宝典》第8章的问题(问题二) </P>
<P>实例255中,我把光盘中的com文件夹(位置是 H:\mingrisoft\08\255\src\)拷贝到了C盘</P>
<P>(说明)————————C:\com\count\Online中有个CountOnline.java <BR>package com.count.Online; <BR><BR>import java.sql.*; <BR>public class CountOnline { <BR>private String userip; <BR>private String nowdate; <BR>private int times; <BR>private DB db=new DB(); <BR>public CountOnline(){} <BR>public void setUserip(String userip){ <BR>this.userip=userip; <BR>} <BR>public String getUserip(){ <BR>return this.userip; <BR>} <BR>public void setNowdate(String nowdate){ <BR>this.nowdate=nowdate; <BR>} <BR>public String getNowdate(){ <BR>return this.nowdate; <BR>} <BR>public void setTimes(int times){ <BR>this.times=times; <BR>} <BR>public int getTimes(){ <BR>return this.times; <BR>} <BR>public ResultSet adduser(){ <BR>ResultSet rs=null; <BR>String sql="insert into tb_IPcount values("+this.times+",'"+this.userip+"','"+this.nowdate+"')"; <FONT color=#ff0000>//我想把表<FONT color=#000000><FONT color=#ff0000>tb_IPcount</FONT> </FONT>改名,关于这些改动,我自己都会,SQL SERVER 2000也会用<BR></FONT>try{ <BR>db.dosql(sql); <BR>rs=db.search("select * from tb_IPcount"); <BR>}catch(Exception e){e.printStackTrace();} <BR>return rs; <BR>} <BR>public void dbclose(){ <BR>db.closed(); <BR>} <BR>} <BR>——————————还有个DB.java <BR>package com.count.Online; <BR><BR>import java.sql.*; <BR><BR>public class DB { <BR>private Connection con; <BR>private Statement stm; <BR>private ResultSet rs; <BR>private String classname="com.microsoft.jdbc.sqlserver.SQLServerDriver"; <BR>private String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=cisco"; <FONT color=#ff0000>//我想把数据库db_database08改成ciosco<BR></FONT><BR>public DB(){} <BR>public Connection getCon(){ <BR>try{ <BR>Class.forName(classname); <BR>} <BR>catch(ClassNotFoundException e){ <BR>e.printStackTrace(); <BR>} <BR>try{ <BR>con=DriverManager.getConnection(url,"sa",""); <BR>} <BR>catch(Exception e){ <BR>e.printStackTrace(System.err); <BR>con=null; <BR>} <BR>return con; <BR>} <BR>public Statement getStm(){ <BR>try{ <BR>con=getCon(); <BR>stm=con.createStatement(); <BR>}catch(Exception e){e.printStackTrace(System.err);} <BR>return stm; <BR>} <BR>public Statement getStmed(){ <BR>try{ <BR>con=getCon(); <BR>stm=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY); <BR>}catch(Exception e){e.printStackTrace(System.err);} <BR>return stm; <BR>} <BR>public ResultSet search(String sql){ <BR>getStm(); <BR>try{ <BR>rs=stm.executeQuery(sql); <BR>}catch(Exception e){e.printStackTrace();} <BR>return rs; <BR>} <BR>public int dosql(String sql){ <BR>int i=-1; <BR>getStm(); <BR>try{ <BR>i=stm.executeUpdate(sql); <BR>}catch(Exception e){e.printStackTrace();} <BR>return i; <BR>} <BR>public void closed(){ <BR>try{ <BR>if(rs!=null)rs.close(); <BR>} <BR>catch(Exception e){e.printStackTrace();} <BR>try{ <BR>if(stm!=null)stm.close(); <BR>} <BR>catch(Exception e){e.printStackTrace();} <BR>try{ <BR>if(con!=null)con.close(); <BR>} <BR>catch(Exception e){e.printStackTrace();} <BR>} <BR>}</CD></P>
<DIV class="wr f14"><SPAN id=suplycontent><B>问题所在:</B>这是我用CMD命令写的编译语句 <BR><BR><BR>C:\com\count\Online>javac CountOnline.java </SPAN></DIV>
<DIV class="wr f14"><SPAN></SPAN> </DIV>
<DIV class="wr f14"><SPAN><STRONG>出现情况:</STRONG></SPAN></DIV><SPAN>
<DIV class="wr f14"><BR>CountOnline.java:8: 找不到符号 <BR>符号: 类 DB <BR>位置: 类 com.count.Online.CountOnline <BR>private DB db=new DB(); <BR>^ <BR>CountOnline.java:8: 找不到符号 <BR>符号: 类 DB <BR>位置: 类 com.count.Online.CountOnline <BR>private DB db=new DB(); <BR>^ <BR>2 错误 </DIV>
<DIV class="wr f14">——————————<STRONG>另外在根目录下 <BR></STRONG>C:\>javac CountOnline.java </DIV>
<DIV class="wr f14"> </DIV>
<DIV class="wr f14"><STRONG>出现情况:</STRONG></DIV>
<DIV class="wr f14"><BR>CountOnline.java:8: 找不到符号 <BR>符号: 类 DB <BR>位置: 类 com.count.Online.CountOnline <BR>private DB db=new DB(); <BR>^ <BR>CountOnline.java:8: 找不到符号 <BR>符号: 类 DB <BR>位置: 类 com.count.Online.CountOnline <BR>private DB db=new DB(); <BR>^ <BR>2 错误</DIV>
<DIV class="wr f14"> </DIV>
<DIV class="wr f14"><STRONG><FONT size=4>最后的问题:</FONT></STRONG></DIV>
<DIV class="wr f14"><STRONG><FONT color=#ff0000 size=4>如何将修改后的 *.java 文件重新成功编译呢???</FONT></STRONG></SPAN></DIV>
<P>实例255中,我把光盘中的com文件夹(位置是 H:\mingrisoft\08\255\src\)拷贝到了C盘</P>
<P>(说明)————————C:\com\count\Online中有个CountOnline.java <BR>package com.count.Online; <BR><BR>import java.sql.*; <BR>public class CountOnline { <BR>private String userip; <BR>private String nowdate; <BR>private int times; <BR>private DB db=new DB(); <BR>public CountOnline(){} <BR>public void setUserip(String userip){ <BR>this.userip=userip; <BR>} <BR>public String getUserip(){ <BR>return this.userip; <BR>} <BR>public void setNowdate(String nowdate){ <BR>this.nowdate=nowdate; <BR>} <BR>public String getNowdate(){ <BR>return this.nowdate; <BR>} <BR>public void setTimes(int times){ <BR>this.times=times; <BR>} <BR>public int getTimes(){ <BR>return this.times; <BR>} <BR>public ResultSet adduser(){ <BR>ResultSet rs=null; <BR>String sql="insert into tb_IPcount values("+this.times+",'"+this.userip+"','"+this.nowdate+"')"; <FONT color=#ff0000>//我想把表<FONT color=#000000><FONT color=#ff0000>tb_IPcount</FONT> </FONT>改名,关于这些改动,我自己都会,SQL SERVER 2000也会用<BR></FONT>try{ <BR>db.dosql(sql); <BR>rs=db.search("select * from tb_IPcount"); <BR>}catch(Exception e){e.printStackTrace();} <BR>return rs; <BR>} <BR>public void dbclose(){ <BR>db.closed(); <BR>} <BR>} <BR>——————————还有个DB.java <BR>package com.count.Online; <BR><BR>import java.sql.*; <BR><BR>public class DB { <BR>private Connection con; <BR>private Statement stm; <BR>private ResultSet rs; <BR>private String classname="com.microsoft.jdbc.sqlserver.SQLServerDriver"; <BR>private String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=cisco"; <FONT color=#ff0000>//我想把数据库db_database08改成ciosco<BR></FONT><BR>public DB(){} <BR>public Connection getCon(){ <BR>try{ <BR>Class.forName(classname); <BR>} <BR>catch(ClassNotFoundException e){ <BR>e.printStackTrace(); <BR>} <BR>try{ <BR>con=DriverManager.getConnection(url,"sa",""); <BR>} <BR>catch(Exception e){ <BR>e.printStackTrace(System.err); <BR>con=null; <BR>} <BR>return con; <BR>} <BR>public Statement getStm(){ <BR>try{ <BR>con=getCon(); <BR>stm=con.createStatement(); <BR>}catch(Exception e){e.printStackTrace(System.err);} <BR>return stm; <BR>} <BR>public Statement getStmed(){ <BR>try{ <BR>con=getCon(); <BR>stm=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY); <BR>}catch(Exception e){e.printStackTrace(System.err);} <BR>return stm; <BR>} <BR>public ResultSet search(String sql){ <BR>getStm(); <BR>try{ <BR>rs=stm.executeQuery(sql); <BR>}catch(Exception e){e.printStackTrace();} <BR>return rs; <BR>} <BR>public int dosql(String sql){ <BR>int i=-1; <BR>getStm(); <BR>try{ <BR>i=stm.executeUpdate(sql); <BR>}catch(Exception e){e.printStackTrace();} <BR>return i; <BR>} <BR>public void closed(){ <BR>try{ <BR>if(rs!=null)rs.close(); <BR>} <BR>catch(Exception e){e.printStackTrace();} <BR>try{ <BR>if(stm!=null)stm.close(); <BR>} <BR>catch(Exception e){e.printStackTrace();} <BR>try{ <BR>if(con!=null)con.close(); <BR>} <BR>catch(Exception e){e.printStackTrace();} <BR>} <BR>}</CD></P>
<DIV class="wr f14"><SPAN id=suplycontent><B>问题所在:</B>这是我用CMD命令写的编译语句 <BR><BR><BR>C:\com\count\Online>javac CountOnline.java </SPAN></DIV>
<DIV class="wr f14"><SPAN></SPAN> </DIV>
<DIV class="wr f14"><SPAN><STRONG>出现情况:</STRONG></SPAN></DIV><SPAN>
<DIV class="wr f14"><BR>CountOnline.java:8: 找不到符号 <BR>符号: 类 DB <BR>位置: 类 com.count.Online.CountOnline <BR>private DB db=new DB(); <BR>^ <BR>CountOnline.java:8: 找不到符号 <BR>符号: 类 DB <BR>位置: 类 com.count.Online.CountOnline <BR>private DB db=new DB(); <BR>^ <BR>2 错误 </DIV>
<DIV class="wr f14">——————————<STRONG>另外在根目录下 <BR></STRONG>C:\>javac CountOnline.java </DIV>
<DIV class="wr f14"> </DIV>
<DIV class="wr f14"><STRONG>出现情况:</STRONG></DIV>
<DIV class="wr f14"><BR>CountOnline.java:8: 找不到符号 <BR>符号: 类 DB <BR>位置: 类 com.count.Online.CountOnline <BR>private DB db=new DB(); <BR>^ <BR>CountOnline.java:8: 找不到符号 <BR>符号: 类 DB <BR>位置: 类 com.count.Online.CountOnline <BR>private DB db=new DB(); <BR>^ <BR>2 错误</DIV>
<DIV class="wr f14"> </DIV>
<DIV class="wr f14"><STRONG><FONT size=4>最后的问题:</FONT></STRONG></DIV>
<DIV class="wr f14"><STRONG><FONT color=#ff0000 size=4>如何将修改后的 *.java 文件重新成功编译呢???</FONT></STRONG></SPAN></DIV>