按书上写了一段java捕获异常的代码,不知道问题出在哪里

源代码如下:
package com.Sixping.Ncre;

public class Rethrow {
public static void rt() throws Exception {//定义方法,抛出Exception类的异常
System.out.println("old exception in rt()");
throw new Exception("thrown from rt()");
}
public static void wq() throws Throwable {//定义方法,调用rt(),捕获rt()抛出的异常
try {
rt();
} catch (Exception e) {
System.out.println("Inside wq(),e.printStackTrace():");
e.printStackTrace(); //输出堆栈使用情况
throw e; //重新抛出异常
}
}
public static void main(String[] args) throws Throwable {
try {
wq(); //产生被重新抛出的对象
} catch (Exception e) {
System.out.println("Caught in main,e.printStackTrace():");
e.printStackTrace(); //再次输出堆栈信息
}
}
}

运行报错如下:
old exception in rt()

java.lang.Exception: thrown from rt()
at com.Sixping.Ncre.Rethrow.rt(Rethrow.java:6)
at com.Sixping.Ncre.Rethrow.wq(Rethrow.java:10)
at com.Sixping.Ncre.Rethrow.main(Rethrow.java:19)
java.lang.Exception: thrown from rt()
at com.Sixping.Ncre.Rethrow.rt(Rethrow.java:6)
at com.Sixping.Ncre.Rethrow.wq(Rethrow.java:10)
at com.Sixping.Ncre.Rethrow.main(Rethrow.java:19)
Inside wq(),e.printStackTrace():
Caught in main,e.printStackTrace():

求大神解答

2个回答

没有错误啊,你不就是测试异常抛出嘛,流程是这样的;
首先,rt()方法抛出了异常,然后你在wq()方法中捕获并上抛出,直至main方法中捕获的是Exception,但是wq抛出的Throwable异常没有处理,所以被main方法继续抛出给虚拟机了。
代码运行是正确的,这不是运行时报错,而是你就是测试的throw e,抛出异常后你在捕获分支中使用的是e.printStack打印堆栈信息了。这个流程是对的,你可以注释调用e.printStackTrace(); 就能发现不会打印堆栈日志了。

代码没有什么语法、逻辑错误。
rt()方法抛出了异常,在wq()方法中捕获并继续抛出,抛给main方法,main方法继续抛给虚拟机,虚拟机能做的就是终止程序。
这些行堆栈日志 信息由e.printStackTrace(); 打印输出

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
不知道问题出在哪里?????
Set cn = New ADODB.Connectionrn cn.Open "dsn=gz;uid=;pwd=;" 'your connection stringrn ProgressBar1.Visible = Truern ProgressBar1.Value = 0rn Set cmdalter = New Commandrn Set cmdupdate = New Commandrn Set rstblset = New Recordsetrn sqltr1 = "select * from tblset order by igznum"rn rstblset.Open sqltr1, cn, 1, 3rn rstblset.MoveLastrn rstblset.MoveFirstrn ProgressBar1.Max = rstblset.RecordCountrn Do While rstblset.EOFrn columnstr = rstblset("cSetGZItemName") & " money"rn With cmdalterrn .ActiveConnection = cnrn .CommandText = "alter table wa_psn add COLUMN " & columnstrrn .Executern End Withrn ProgressBar1.Value = ProgressBar1.Value + 1rn rstblset.MoveNextrn Looprn MsgBox "所有工资数据已经导入"
一段多线程代码,不知道问题出在什么地方
[code=C#][/code]rnrn定义了一个全局集合rnprivate List _testThreads = new List();rn时钟中有如下一段代码rnprivate void tmrTest_Tick(object sender, EventArgs e)rnrnrn for (int i = 0; i < _testThreads.Count; i++)//如果定时器到时,但做通讯测试的线程还没有结束rn rn if (_testThreads[i].IsAlive)rn rn _testThreads[i].Join();rn rn rnrn Thread.Sleep(350);rnrn //用多线程进行通讯测试rn for (int index = 0; index < _seiPcbas.Count; index++)rn rn _seiPcbas[index].SetTestCondition(cmbCommand.Text, _repeatTimes, _repeatInterval, rn new CallBackDelegate(CallBackRecord));rn Thread threadTest = new Thread(new ThreadStart(_seiPcbas[index].TestReadCommand));rn _testThreads.Add(threadTest);rn threadTest.Start();rn rnrnrn想在点击"停止"按钮时,首先停止时钟,然后终止线程或等待线程结束,但用Join不动了,用Abort又除出现rn如下错误:rn未处理 System.ObjectDisposedExceptionrn Message="已关闭 Safe handle"rn Source="mscorlib"rn ObjectName=""rn StackTrace:rn 在 Microsoft.Win32.Win32Native.SetEvent(SafeWaitHandle handle)rn 在 System.Threading.EventWaitHandle.Set()rn 在 System.IO.Ports.SerialStream.AsyncFSCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOverlapped)rn 在 System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)rnrn请高手指教
按书上写了一段程序不知怎么调试
我按书上写了一段程序,但一执行就不能通过,有这样的提示条:rn________________________________________________________________________________________rn 无法直接启动带"类库输出题类型"的项目rn 若要调试此项目,请转到"项目属性"中"配置设置"下的"调试"选项卡,将"启动操作"设置为"启动外部程序"或"启动URL"rn 另一种方法是可以将一个使用此项目引用的非库项目添加到该解决方案中并将它设置为启动项目rn________________________________________________________________________________________rn请大家帮我看一下应怎么样才能调试程序 具体的设置应怎么设 我根本没有找到它的提示上说的东西rn并请说明一下为什么会出现这个问题
不知道问题出在哪里...fstream问题
不知道怎样才能把红色字部分的内容写在txt里面rn刚学C++...囧rn#include rn#include rn#include rnrnusing namespace std;rnrnint height, feet, inches, weight;rndouble BMI;rnrnint main() rn string height, feet, inches, weight, BMI;rnrn ofstrem outfile;rn outfile.open("HW.txt");rnrnrn void promptUser(void);rnrn outfile.setf(ios::fixed,ios::floatfield);rnrn promptUser();rnrnrn while (BMI > 0) rn if (BMI < 18.5) rn [color=#FF0000]outfile << "Your MBI is " << BMI << ", "rn << "indicating your weight is in the Underweight category\n"rn << "for adults of your height" << endl << endl;[/color]rn promptUser();rn rnrn if ((BMI >= 18.5) && (BMI < 24.9)) rn [color=#FF0000]outfile << "Your MBI is " << BMI << ", "rn << "indicating your weight is in the Normal category\n"rn << "for adults of your height" << endl << endl;[/color]rn promptUser();rn rnrn if ((BMI >= 25.0) && (BMI < 29.9)) rn [color=#FF0000]outfile << "Your MBI is " << BMI << ", "rn << "indicating your weight is in the Overweight category\n"rn << "for adults of your height" << endl << endl;[/color]rn promptUser();rn rnrn if (BMI >= 30.0) rn [color=#FF0000]outfile << "Your MBI is " << BMI << ", "rn << "indicating your weight is in the Obese category\n"rn << "for adults of your height" << endl << endl;[/color]rn promptUser();rn rn rn outfile.close();rn system("PAUSE");rn return EXIT_SUCCESS;rnrnrnrnvoid promptUser() rnrn cout << "Enter the patient's height"rn << "(in ft and inches-Enter 0 0 to stop): ";rn cin >> feet >> inches;rn cout << "Enter the patient's weight(in pounds): " ;rn cin >> weight;rnrn height = 12 * feet + inches;rn cout.precision(1);rn BMI = weight * 703 / ( height * height );rnrn [color=#FF0000] outfile << "Height: " << feet << " feet, "rn << inches << " inches" << endl;rn outfile << "Weight: " << weight << " pounds" << endl;[/color]rnrn
书上一段不了解的代码
rn rn//从表单获取数据到JS的函数里面计算rn数字:*rn rnrn rn//输出结果rn他的2倍是:rnrn这个是我一本书上出现的代码,发现我运行老是得不到结果,大家帮忙看下是那里出了问题,最好是把修好的代码全部给我看下下
更新问题,不知道问题出在哪里?!!!困惑。。。。
rn<%rndim i,j,g,hrni=1 rnj=i+2rng="text"& irnh="text"& jrn%>rn<%rnrnif(request.form(g) <> "") then Command1__c = request.form(g)rnrnif(request.form(h) <> "") then Command1__d = request.form(h)rnrn%>rn<%rnrnset Command1 = Server.CreateObject("ADODB.Command")rnCommand1.ActiveConnection = MM_nana_STRINGrnCommand1.CommandText = "UPDATE dbo.ab SET a ='" + Replace(Command1__c, "'", "''") + "', b ='" + Replace(Command1__d, "'", "''") + "' WHERE ID='i' "rnCommand1.CommandType = 1rnCommand1.CommandTimeout = 0rnCommand1.Prepared = truernCommand1.Execute()rnrn%>rnrnrnrn rn rn rn rn rnrnrnrnrnrnrn不知为什么不能完成更新,我想问题大概出在WHERE ID='i' 这句语句上,当我把i改成具体数字时,不如1时,就可以更新,什么问题呢?!!!!困惑。。。。
--悲哀:按书上写了个存储过程,不知道咋调用--
[code=SQL]--主要是那个输出参数为布尔型 变量,怎么在SQL Plus中定义啊?rncreate or replacernprocedure UPDATE_EMP(p_empno number, p_decrease number,rnp_success out boolean)rnisrnbeginrnif p_decrease = 0 thenrn p_success := false;rnelsern update EMPrn set SAL = SAL / p_decreasern where empno = p_empno;rn p_success := true;rnend if;rnend;rn/rnrn-------------------------------------rnrn--望高人指点一、二! 谢谢......[/code]
按书上写了个循环链表的类,析构函数不知道怎么写
[code=C/C++]rn#pragma oncernrnstruct NodeTypernrn NodeType* next;rn NodeType* back;rn int info;rn;rnrnclass SpecializedListrnrnpublic:rn SpecializedList(void);rn ~SpecializedList(void);rn SpecializedList(const SpecializedList& somelist);rn void ResetForward();rn void GetNextItem(int& item, bool finished);rn void ResetBackward();rn void GetPriorItem(int& item, bool finished);rn void InsertFront(int item);rn void InsertEnd(int item);rn int InsertItem(int item,int index);rn int Length();rnprivate:rn NodeType* head;rn NodeType* currentNextPos;rn NodeType* currentBackPos;rn int length;rn;rnrnrn#include "SpecializedList.h"rnrnSpecializedList::SpecializedList(void)rnrn length = 0;rn head = NULL;rnrnrnSpecializedList::~SpecializedList(void)rnrn if(head != NULL)rn rn head = head->next;rn delete head;rn rn elsern delete head;rnrnrnvoid SpecializedList::ResetForward()rnrn currentNextPos = NULL;rnrnrnvoid SpecializedList::GetNextItem(int &item, bool finished)rnrn if(currentNextPos == NULL)rn currentNextPos = head->next;rn elsern currentNextPos = currentNextPos->next;rn item = currentNextPos->info;rn finished = (currentNextPos == head);rnrnrnvoid SpecializedList::ResetBackward()rnrn currentBackPos = NULL;rnrnrnvoid SpecializedList::GetPriorItem(int& item, bool finished)rnrn if(currentBackPos == NULL)rn currentBackPos = head;rn elsern currentBackPos = currentBackPos->back;rn item = currentBackPos->info;rn finished = (currentBackPos == head);rnrnrnrnvoid SpecializedList::InsertFront(int item)rnrn NodeType* newNode = new NodeType;rn newNode->info = item;rn if(head == NULL)rn rn newNode->back = newNode;rn newNode->next = newNode;rn head = newNode;rn rn elsern rn newNode->back = head;rn newNode->next = head->next;rn head->next->back = newNode;rn head->next = newNode;rn rn length++;rnrnrnvoid SpecializedList::InsertEnd(int item)rnrn InsertFront(item);rn head = head->next;rnrnrnint SpecializedList::InsertItem(int item, int index)rnrn if(index >= length)rn return 0;rn elsern rn NodeType* p = head;rn for(int i=1;inext;rn rn NodeType* newNode = new NodeType;rn newNode->next = p->next;rn newNode->back = p;rn p->next->back = newNode;rn p->next = newNode;rn length++;rn return 1;rn rnrnrnint SpecializedList::Length()rnrn return length;rnrn[/code]rnrn主要是SpecializedList的析构函数,~SpecializedList(void)是不是该这样写?如果一个指针被置位成NULL了,还需要用delete么?
以下代码问题出在哪里?
在一个基于CRichEditView的单文档程序,添加一菜单项,单击时执行以下代码rnvoid CMyEditorDoc::OnLoad() rnrn char buf[1032740];//为什么加大buf后,例如改为char buf[1040000]后运行会出错rn int off=0;rn CRichEditView *pView=GetView();rn CRichEditCtrl &edit=pView->GetRichEditCtrl();rn //for(int i=0;i<130000;i++)rn //rn // wsprintf(buf+off,"%d\r\n",i);rn // off+=strlen(buf+off);rn //rn for(int i=0;i<130000;i++)rn off +=sprintf(buf + off , "%d\r\n" , i);rn edit.SetSel(0,-1);rn edit.ReplaceSel(buf);rnrn
这代码问题出在哪里?
[code=VB]Private Sub Command1_Click()rnSet cn1 = New ADODB.ConnectionrnIf cn1.State <> adStateClosed Then cn1.Closern cn1.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\数据库\账单信息表(1).mdb;Persist Security Info=False"rn'rs.CursorLocation = adUseClientrni = Val(Text1.Text)rns = Val(Text2.Text)rnIf Trim(Text1.Text) = "" Or Trim(Text2.Text) = "" Thenrn MsgBox "请输入有效的年月!", 48, "提示"rn Exit SubrnElsernIf i > Year(Now) Thenrn MsgBox "还没到这一年!", 48, "提示"rn Exit SubrnrnEnd IfrnIf rs1.State <> adsateclosed Then rs1.Closern rs1.Open " select 花销 from 表1 where year(日期) = " & Text1.Text & " and month(日期) = " & Text2.Text & " ", cn1, adOpenDynamic, adLockOptimisticrn price = 0rn While rs1.EOF = Falsern price = price + Val(rs1.Fields(0))rn rs1.MoveNextrn Wend[/code] 这段代码运行时输入一个太大的数字,就会出现溢出的提示。
这段代码问题出在哪里?
出现异常了 请教高手!rnimport java.util.*;rnpublic class tree rn int s ;rn tree (int j)rn s=j;rn rn public static void main(String[] args) rn TreeMap t=new TreeMap();rn for (int i=0;i<5;i++)rn t.put(new tree(i),new Integer(i+2));rn System.out.print(t);rn rn
这段代码的问题出在哪里
我通过ADO.net创建表rnrnstring strCnn = "server='ls'; user id='ls'; password=2094; database='LS'";rnstring strCmm = "Create Table tempTable (name varchar(50), age int, date date)";rnSqlConnection cnn = new SqlConnection(strCnn);rnSqlCommand cmm = new SqlCommand(strCmm, cnn);rncnn.Open();rncmm.ExecuteNonQuery(); //这行代码删除后,调试才可通过rncnn.Close();rnrn如何修改才可通过,并创建表?
这段代码问题出在哪里
如题 我想从组合框中获得一个信息 然后将这个信息放到另外一个表中 无法实现 代码如下rnvoid Cxiaoshou::OnButton1() rnrn // TODO: Add your control notification handler code herern UpdateData();rn CString x,y;rn m_goodsname.GetWindowText(x);rn m_proname.GetWindowText(y);rn CString goodscode,providercode;rn Cxiaoshougood good;rn Cxiaoshoupro provider;rn if(good.IsOpen())rn good.Close();rn good.m_strFilter.Format("G_name='%s'",x);rn good.Open();rn goodscode=good.m_G_code;rn good.Edit();rn good.m_Current_number=good.m_Current_number-m_num;rn good.Update();rn if(provider.IsOpen())rn provider.Close();rn provider.m_strFilter.Format("provider_name='%s'",y);rn provider.Open();rn providercode=provider.m_provider_code;\\想provider表中获取provider编号rnrn Coutlib outlib;rn outlib.Open();rn outlib.AddNew();rn outlib.m_goods_code=goodscode;rn outlib.m_provider_code=providercode;\\想将provider编号放到outlib.m_provider_code中rn outlib.m_out_number=m_num;rn outlib.m_out_single=m_price;rn outlib.m_out_date=m_date;rn outlib.Update();rn outlib.Requery();rn MessageBox("操作已成功,请按查看按钮进行确认");rnrn rnrnrn想实现这样的功能 编译连接无错 却达不到我想要的效果 请问该如何修改 谢谢
有一段代码看了两年就是不知道问题出在什么地方。
; 5.9 从字符串 eng 中找出单词 sun 的个数rn;************************************************rndatarea segmentrnrn mess db "sun is $"rnrndatarea endsrn;************************************************rnextra segmentrnrn eng db "sun sun sun sun sun $"rnrnextra endsrn;************************************************rnprogram segmentrn;------------------------------------------------rnmain proc farrn rn assume cs:program, ds:datarea, es:extrarnrnstart:rn push dsrn sub ax, axrn push axrnrn mov ax, datarearn mov ds, axrn mov ax, extrarn mov es, axrnrn sub bx, bxrnrn lea di, engrn mov cx, 21rnrnnext: mov al, 's'rn cldrn repne scasbrn jcxz outputrn rn mov al, 'u'rn cmp byte ptr [di], alrn jne nextrn mov al, 'n'rn cmp byte ptr [di+1], alrn jne nextrnrn inc bl ;sun 的数量rn jmp nextrnrnoutput: lea dx, messrn mov ah, 9rn int 21hrnrn mov dl, blrn add dl, 30hrn mov ah, 2rn int 21hrnrn retrnrnmain endprn;------------------------------------------------rnprogram endsrn;************************************************rn end startrnrn最后的结果总是2,而不是5。问题应该是出在下面一段代码中。删掉下面的代码后结果正常。rnrn mov al, 'u'rn cmp byte ptr [di], alrn jne nextrn mov al, 'n'rn cmp byte ptr [di+1], alrn jne nextrnrn只是不知道具体在哪里。这段代码的问题在什么地方。
Servlet没反应,不知道问题出在哪里?
public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOExceptionrn String login_error = new String();rn response.setContentType(CONTENT_TYPE);rn String username = new String(ParameterUtils.getString(request,"UserName").getBytes("iso-8859-1"),"gbk");rn String password = new String(ParameterUtils.getString(request,"Password").getBytes("iso-8859-1"),"gbk");rn HttpSession httpsession = request.getSession();rn SessionManager session = new SessionManager();rn rn Factory factory = Factory.getInstance();rn User user = factory.getUser();rn UserFactory userfactory = factory.getUserFactory();rn int state = userfactory.ChkUser(username,password);rn if(state==1)rn response.sendRedirect("index.jsp");rn session.setSession(httpsession,"SignUp",user.getUsername());rn rn elsern login_error = " 请确认用户名和密码,T.T,返回";rn session.setSession(httpsession,"login_errors", login_error);rn response.sendRedirect("login.jsp");rn rn rn rn public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOExceptionrn doGet(request,response);rn rnrn-----------rn方法rn public int ChkUser(String username,String password)rn int state = 0;rn User user = Factory.getInstance().getUser();rn user = this.List(username);rn if(user != null)rn if(password.equals(user.getPassword()))rn state = 1;rn rn else state = 0;rn else state = 0;rn rn return state;rn rnrn没有报错,就是没有反应
高手指教!!我不知道问题出在哪里。
用VB编下面问题: rn 只要输入正方形的边长就会输出正方形它的面积和周长。 rn 我用代码这样写对不? rn Dim r As Double rn Dim mianji As Double rn Dim zhouchang As Double rn r=Val(InputBox("输入数值")) rn Print"r="&r rn mianji=r*r rn zhouchang=4*r rn Print"mianji="&mianji&"zhouchang"&zhouchang rn 就这样;我想它应该错了,执行不了,出错。 rn 麻烦高手指点指点。 谢谢了!
我要受不了了!不知道问题究竟出在哪里!
我再程序里添加了frReport1,table1,DataSource1,frDBDataSet1rn我进入到报表设计器,编辑好了一个报表的页面存书为3.frf。rn在设计好的报表内我添加了报表标题,页头,主数据项,页脚。rnfrDBDataSet1的数据源连接到了DataSource1。rnDataSource1连接到了table1。rn主数据项的数据源连接到了frDBDataSet1。rnrn有个一个按钮是用来显示报表的打印预览的,用了一下语句:rnfrReport1.LoadFromFile('3.frf');rnfrReport1.ShowReport;rnrn然后我再表内添加了几个TfrMemoView,然后把放到了主数据项地band上,这些TfrMemoView都指向了table1表的field。rnrn然后我就用设计器内的预览,可以看到报表已经把数据库内的数据全都显示出来了。rnrn接下来我运行程序,按下按钮但是显示的报表的数据只有数据库内的第一条记录。rnrn我运到这个问题已经很久了但是就不知道问题在哪里!rnrn
phpmailer2.1发送邮件失败,不知道问题出在哪里!
[code=PHP]getFile('codeworxtech.html');rn$body = "test email ";rnrn$mail->IsSMTP();rn$mail->SMTPAuth = true; // enable SMTP authenticationrn$mail->SMTPSecure = "ssl"; // sets the prefix to the servierrn$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP serverrn$mail->Port = 465; // set the SMTP portrnrn$mail->Username = "freebooy@gmail.com"; // GMAIL usernamern$mail->Password = "windows"; // GMAIL passwordrnrn$mail->From = "myllop@gmail.com";rn$mail->FromName = "Webmaster";rn$mail->Subject = "This is the subject";rn$mail->AltBody = "This is the body when user views in plain text format"; //Text Bodyrn$mail->WordWrap = 50; // set word wraprnrn$mail->MsgHTML($body);rnrn$mail->AddReplyTo("myllop@gmail.com","Webmaster");rnrn//$mail->AddAttachment("/path/to/file.zip"); // attachmentrn//$mail->AddAttachment("/path/to/image.jpg", "new.jpg"); // attachmentrnrn$mail->AddAddress("myllop@qq.com","First Last");rnrn$mail->IsHTML(true); // send as HTMLrnrnif(!$mail->Send()) rn echo "Mailer Error: " . $mail->ErrorInfo;rn else rn echo "Message has been sent";rnrnrn?>[/code]
窗体背景不透明,不知道问题出在哪里了!
我把窗体的formborderstyle设置成了none,加入了一幅背景位图,Transparencykey设置成白色,位图的背景也是白色的,但是运行的时候背景都没有如期所想的透白,而是白色,不知道问题出在哪里了?
不知道问题出在哪里了,帮忙看下!
[code=C/C++]rn#ifndef _vectorrn#define _vectorrnclass CVectorrnrnprivate:rn float *p_val;rn int size;rnpublic:rn CVector(int s)//单参数构造函数rn rn size = s;rn p_val = new float[size];rn if(p_val == NULL)rn exit(1);rn rn CVector(const float *p_v, int s)//构造函数rn rn size = s;rn p_val = new float[size];rn if(p_val == NULL)rn exit(1);rn for(int i = 0; i < size; i++)rn p_val[i] = p_v[i];rn rn CVector(const CVector &v) //拷贝构造函数rn rn p_val = new float[size];rn for(int i = 0; i < size; i++)rn p_val[i] = v.p_val[i];rn rn ~CVector()delete [] p_val;//析构函数rn CVector & operator=(const CVector &v)//赋值运算符重载函数rn rn if(this == &v)rn return* this;rn delete p_val;rn p_val = new float[size];rn for(int i = 0; i < size; i++)rn p_val[i] = v.p_val[i];rn return* this;rn rn float &operator[](int ix)//下标运算符重载函数rn rn if(ix < 0 || ix > size)rn exit(1);rn return p_val[ix];rn rn friend CVector operator +(const CVector &r_v1, const CVector &r_v2)//加法运算rn rn if(r_v1.size != r_v2.size)rn exit(1);rnrn CVector sum[rv1.size] = 0;rn for(int i = 0; sum[i] != '\0'; i++)rn sum.p_val[i] = r_v1.p_val[i] + r_v2.p_val[i];rn return sum;rn rn friend CVector operator-(const CVector &r_v1, const CVector &r_v2)//加法运算rn rn if(r_v1.size != r_v2.size)rn exit(1);rnrn CVector m[rv1.size] = 0;rn for(int i = 0; m[i] != '\0'; i++)rn m.p_val[i] = r_v1.p_val[i] - r_v2.p_val[i];rn return m;rn rn friend CVector operator*(const CVector &r_v1, const CVector &r_v2)//加法运算rn rn if(r_v1.size != r_v2.size)rn exit(1);rnrn CVector M[rv1.size] = 0;rn for(int i = 0; M[i] != '\0'; i++)rn M.p_val[i] = r_v1.p_val[i] + r_v2.p_val[i];rn return M;rn rn friend CVector operator/(const CVector &r_v1, const CVector &r_v2)//加法运算rn rn if(r_v1.size != r_v2.size)rn exit(1);rnrn CVector D[rv1.size] = 0;rn for(int i = 0; D[i] != '\0'; i++)rn D.p_val[i] = r_v1.p_val[i] + r_v2.p_val[i];rn return D;rn rn friend bool operator>(const CVector &r_v1, const CVector &r_v2)//大于运算符重载rn rn if(r_v1.size > r_v2.size)rn return true;rn elsern return false;rnrn float sum1 = 0.0, sum2 = 0.0;rn for(int i = 0; i < r_v1.size; i++)rn rn sum1+=r_v1.p_val[i];rn sum2+=r_v2.p_val[i];rn rn if(sum1 > sum2)rn return true;rn return false;rn rn friend bool operator==(const CVector &r_v)//恒等于运算符重载rn rn return strcmp(p_val,r_v.p_val) == 0;rn rn friend bool operator<(const CVector &r_v)//小于运算符重载rn rn return strcmp(p_val,r_v.p_val) < 0;rn rn;rn#endifrnvoid main()rn[/code]rn编译的时候出现这个错误,网上查了下,说其实不是编译错误是所编译的函数跟库函数的函数名重名了,但是看了下程序并没有啊!rnfatal error C1001: INTERNAL COMPILER ERRORrn (compiler file 'msc1.cpp', line 1786) rn Please choose the Technical Support command on the Visual C++ rn Help menu, or open the Technical Support help file for more informationrn请各位帮忙看下!rn
各位高手请看--不知道问题出在哪里
各位高手请看---这个函数在SQL2000执行正常-在SQL2005出错-不知道问题出在哪里rn[code=sql]rnCREATE FUNCTION dbo.f_getdatetag_y(@tdate datetime) RETURNS float rn AS rn BEGIN rn DECLARE @r1 float rn DECLARE @r2 float rn select @r1= (select top 1 isnull(标识号,0) from store_y where convert(datetime, convert(varchar(10),时间,120))= convert(datetime, convert(varchar(10),@tdate,120)) order by 标识号 desc) rn if isnull(@r1,0)>0 rn set @r2 =@r1+ 0.00001 rn Else rn set @r2 =convert(float,convert(varchar(8),@tdate,112))+ 0.00001 rn RETURN @r2 rn End rn[/code]rn这个函数是库存表根据日期产生一个标识好,例如:2016-1-28,第一个产生的就是20160128.00001,第二个20160128.00002,以此类推。rnrn执行的语句为:rn[code=sql]rninsert into store_y(单号,产品编码,数量,单价,时间,备注,标识号) select 入库单号,产品编码,数量,单价日期,备注, dbo.f_getdatetag_y(getdate() from ruku_y_pj where 入库单号='F20160128-0001'rn[/code]rnrn或者有没有其他好的方法产生类似的编号呢?高手们!~~~不胜感谢!rn
cannot find symbol不知道问题出在哪里
在同一个包下,我建立了两个Java文件(做Javabean的),分别为UserBean.java 和UserCheckBean.java。(UserCheckBean调用UserBean)先编译好UserBean成功后,再编译UserCheckBean.java时却出现 cannot find symbol ( UserBean)字样。 rn 后来,我没有按照先后顺序编译,而是直接 Java *.java 这样就都编译成功了。这是为什么呢?因为我的两个源码存在明显的先后关系( UserCheckBean调用UserBean),那为什么分开编译后就不可以了呢????? rn谢谢 rnUserBean.java 代码:rnpackage com.itzcn.jack.chapter2;rnpublic class UserBeanrnrn private String name;rn private String password;rn rn public String getName()rn rn return name;rn rn public void setName(String name)rn rn this.name=name;rn rn public String getPassword()rn rn return password;rn rn public void setPassword(String password)rn rn this.password=password;rn rn rnrnUserCheckBean.java代码:rnpackage com.itzcn.jack.chapter2;rnrnpublic class UserCheckBeanrnprotected UserBean user;rnpublic UserCheckBean()rn rn rnpublic UserCheckBean(UserBean user)rnrn this.user=user;rn rnpublic UserBean getUser()rnrn return user;rn rn rnpublic boolean checkUser()rnrn String name=user.getName();rn String password=user.getPassword();rn if(name.equals("赵兴")&&password.equals("123"))rn return true;rn elsern return false;rn rnrnrn错误:rnUserCheckBean.java:4: cannot find symbolrnsymbol : class UserBeanrnlocation: class com.itzcn.jack.chapter2.UserCheckBeanrnprotected UserBean user;rn ^rnUserCheckBean.java:8: cannot find symbolrnsymbol : class UserBeanrnlocation: class com.itzcn.jack.chapter2.UserCheckBeanrnpublic UserCheckBean(UserBean user)rn ^rnUserCheckBean.java:12: cannot find symbolrnsymbol : class UserBeanrnlocation: class com.itzcn.jack.chapter2.UserCheckBeanrnpublic UserBean getUser()rn ^rn3 errors
一段身份证识别性别日期的程序,不知道错误出在哪里?
varrn ID:String;rn i:integer;rn Month,Day:string;rnbeginrn while not datamodule2.tvquery.Eof dorn beginrn ID:=Trim(datamodule2.tvquery.FieldByName('id_card').AsString);rn if (Length(ID)<>15) And (Length(ID)<>18) thenrn beginrn tvquery.Next;rn //Exit;rn end;rn //判断年月日的正确性rn if Length(ID)=15 thenrn beginrn Month:=Copy(ID,9,2);rn Day:=Copy(ID,11,2);rn endrn else if Length(ID)=18 thenrn beginrn Month:=Copy(ID,11,2);rn Day:=Copy(ID,13,2);rn end;rn if not (((StrToInt(Month))>=01) and ((StrToInt(Month))<=12)) thenrn beginrn tvquery.Next;rn end;rn if not (((StrToInt(Day))>=01) and ((StrToInt(Day))<=31)) thenrn beginrn tvquery.Next;rn end;rn if (StrToInt(Copy(ID,15,1)) Mod 2)=0 thenrn beginrn tvquery.Edit;rn tvquery.FieldByName('sex').AsString:='女';rn tvquery.post;rn tvquery.Next;rn endrn elsern beginrn tvquery.Edit;rn tvquery.FieldByName('sex').AsString:='男';rn tvquery.post;rn tvquery.Next;rn end;rn if (StrToInt(Copy(ID,17,1)) Mod 2)=0 thenrn beginrn tvquery.Edit;rn tvquery.FieldByName('sex').AsString:='女';rn tvquery.post;rn tvquery.Next;rn endrn elsern beginrn tvquery.Edit;rn tvquery.FieldByName('sex').AsString:='男';rn tvquery.post;rn tvquery.Next;rn end ;rn end;rn我是想执行这段代码先检查身份证号码是否正确,校验位数,然后看日期是否合理,然后提取18位身份证的倒数第二位,或者15位身份证的最后一位看性别,把性别赋值给sex字段.但是我现在这段程序的问题是遇到空值的时候就出错.
谁能帮我看下这段代码。。=w=不知道问题出在哪里
我前台有一个repeater控件,可是不知道为什么绑定后的数据会出现问题,数据都显示的相同一条,但我把sql语句放到数据库里面查的数据缺失不同的rnrn我dal层这么写的rnrn public static DataTable GetOvertimeSheet(int utype, int uid, int did)rn rn object a = utype;rn rn List list = new List();rn using (SqlConnection con = new SqlConnection(DBhelper.connectionString))rn rn DataSet ds = new DataSet();rn string sql="select B.ID ,EmployeeID,B.SerialNumber,ExpectStartTime,ExpectEndTime,StartTime,EndTime,LeaveType,LeaveReason,ApproveStatus,ApplyLevel,LeaveStatus,B.UserID,LastUpdateTime,CreateTime,IsDel, T.Name,T.SerialNumber,T.PositionID,T.DepartmentID,T.UserID,T1.G_CName as DepartmentNa,T1.GroupID,T2.GroupID,T2.G_CName as Position,T3.U_Type from tb_OvertimeSheet as B INNER JOIN tb_EmployeesInfo as T On B.UserID = T.UserID INNER JOIN sys_Group as T1 On T.DepartmentID = T1.GroupID INNER Join sys_Group as T2 on T.PositionID =T2.GroupID INNER Join sys_User as T3 on B.UserID =T3.UserID where LeaveStatus = 0 and T3.U_Type between @Utype and @tys and b.UserID = @uid and T.DepartmentID = @did order by B.CreateTime DESC";rn SqlCommand cmd = new SqlCommand(sql.ToString(), con);rn con.Open();rn cmd.Parameters.Add("@Utype", SqlDbType.TinyInt).Value = utype - 1;rn cmd.Parameters.Add("@tys", SqlDbType.TinyInt).Value = utype;rn cmd.Parameters.Add("@uid", SqlDbType.Int).Value = uid;rn cmd.Parameters.Add("@did", SqlDbType.Int).Value = did;rnrn SqlDataAdapter adp = new SqlDataAdapter(cmd);rn adp.Fill(ds);rnrn return ds.Tables[0];rn rn rn rnrn public static List getLists(int utype, int uid, int did)rn rn DataTable dt = GetOvertimeSheet(utype, uid, did);rn return getList(dt);rn rn rnrn public static List getList(DataTable dt) rn List lists = new List();rnrn int counts = dt.Rows.Count;rn if (counts > 0) rn tb_OvertimeSheetTable b = new tb_OvertimeSheetTable();rn for (int i = 0; i < counts; i++)rn rn if (dt.Rows[i]["ExpectStartTime"].ToString() != "") rn b.ExpectStartTime = Convert.ToDateTime(dt.Rows[i]["ExpectStartTime"].ToString());rn rn if (dt.Rows[i]["ExpectEndTime"].ToString() != "")rn rn b.ExpectEndTime = Convert.ToDateTime(dt.Rows[i]["ExpectEndTime"].ToString());rn rn if (dt.Rows[i]["CreateTime"].ToString() != "")rn rn b.CreateTime = Convert.ToDateTime(dt.Rows[i]["CreateTime"].ToString());rn rn if (dt.Rows[i]["ApproveStatus"].ToString() != "") rn b.ApproveStatus = Convert.ToInt32(dt.Rows[i]["ApproveStatus"].ToString());rn rn if (dt.Rows[i]["ApplyLevel"].ToString() != "")rn rn b.ApplyLevel = Convert.ToInt32(dt.Rows[i]["ApplyLevel"].ToString());rn rn b.Name =dt.Rows[i]["Name"].ToString();rn b.DepartmentName = dt.Rows[i]["DepartmentNa"].ToString();rn b.PositionName = dt.Rows[i]["Position"].ToString();rn b.ID = Convert.ToInt32(dt.Rows[i]["ID"]);rn lists.Add(b); rn rn rn return lists;rn rnrn谁能帮我看下哦。。=w=是不是for循环的赋值问题
我写了一段代码,出现了内存泄露,不知道哪里的问题,高手指点下,附代码
void COScopeCtrl::InvalidateCtrl()rn rn //初始化参数rn //初始化位置参数rn CBrush *oldbrush;rn CPen *oldPen ;rn CRect rect[7];rnrn CString strTemp ;rn double numtemp;rn double numinterval;rn //填充CRgn的画刷rn CBrush brA, brB;rn //设置字体颜色rn CFont nunberfont, *oldFont ;rn CFont nunberfont1;rn CFont nunberfont2;rn // 绘制刻度变量rn int i,x5,y5,x6,y6;rn int biger_interval=4; //大刻度数rn //绘制屏蔽线rn CPen temppen,temppen1;rn //绘制边框rn CPen form_pen;rn //表盘边界rn int x1,x2,x3,x4,y1,y2,y3,y4; rn SetCentre();rn CheckB();rn rn x1=m_centrex-m_radii;rn y1=m_centrey-m_radii;rn x2=m_centrex+m_radii;rn y2=m_centrey+m_radii;rn x3=(int)(m_centrex+m_radii*sin(m_angle/2));rn y3=(int)(m_centrey-m_radii*cos(m_angle/2));rn x4=(int)(m_centrex-m_radii*sin(m_angle/2));rn y4=y3;rn rn // in case we haven't established the memory dc'srn CClientDC dc(this) ; rn rn // if we don't have one yet, set up a memory dc for the gridrn if (m_dcindex.GetSafeHdc() == NULL)rn rn m_dcindex.CreateCompatibleDC(&dc) ; //内存DCrn m_bitmapidex.CreateCompatibleBitmap(&dc, m_rectClient.right-m_rectClient.left, m_rectClient.bottom-m_rectClient.top) ;rn m_pbitmapOldindex = m_dcindex.SelectObject(&m_bitmapidex) ;rn rn elsern rn m_dcindex.DeleteDC();rn m_bitmapidex.DeleteObject();rn m_pbitmapOldindex->DeleteObject();rn rn m_dcindex.CreateCompatibleDC(&dc) ; //内存DCrn m_bitmapidex.CreateCompatibleBitmap(&dc, m_rectClient.right-m_rectClient.left, m_rectClient.bottom-m_rectClient.top) ;rn m_pbitmapOldindex = m_dcindex.SelectObject(&m_bitmapidex) ;rn rnrn m_dcindex.SetBkColor (m_crBackColor);rn m_dcindex.FillRect(m_rectClient, &m_brushBack) ;rnrn //利用CRGN绘制图形rn if (m_Crgn_flag)rn rn m_rgn1.DeleteObject();rn m_rgn2.DeleteObject();rn m_rgn3.DeleteObject();rn m_rgn4.DeleteObject();rn m_Crgn_flag=false;rn rn CPoint ptVertex1[3];rn CPoint ptVertex2[3];rn CPoint ptVertex3[3];rn CPoint ptVertex4[3];rnrn ptVertex1[0].x = m_rectClient.right-5;rn ptVertex1[0].y = m_rectClient.bottom-7-5;rn ptVertex1[1].x = m_rectClient.right-5-7;rn ptVertex1[1].y = m_rectClient.bottom-5;rn ptVertex1[2].x = m_rectClient.right-5-7-7;rn ptVertex1[2].y = m_rectClient.bottom-5-7;rn rn ptVertex2[0].x = m_rectClient.right-4;rn ptVertex2[0].y = m_rectClient.bottom-7-2-5;rn ptVertex2[2].x = m_rectClient.right-5-7;rn ptVertex2[2].y = m_rectClient.bottom-5-8-7-2;rn ptVertex2[1].x = m_rectClient.right-5-8-7;rn ptVertex2[1].y = m_rectClient.bottom-5-7-2;rnrn ptVertex3[0].x = m_rectClient.right-5-7-7-3;rn ptVertex3[0].y = m_rectClient.bottom-7-5;rn ptVertex3[1].x = m_rectClient.right-5-7-7-7-3;rn ptVertex3[1].y = m_rectClient.bottom-5;rn ptVertex3[2].x = m_rectClient.right-5-7-7-7-3;rn ptVertex3[2].y = m_rectClient.bottom-5-7-7;rn rn ptVertex4[0].x = m_rectClient.right-5-7-7-7-2-3;rn ptVertex4[0].y = m_rectClient.bottom-4;rn ptVertex4[2].x = m_rectClient.right-5-7-7-7-2-3;rn ptVertex4[2].y = m_rectClient.bottom-5-8-7;rn ptVertex4[1].x = m_rectClient.right-5-9-7-3-7-7;rn ptVertex4[1].y = m_rectClient.bottom-5-7;rn m_rgn1.CreatePolygonRgn( ptVertex1, 3, ALTERNATE);rn m_rgn2.CreatePolygonRgn( ptVertex2, 3, ALTERNATE);rn m_rgn3.CreatePolygonRgn( ptVertex3, 3, ALTERNATE);rn m_rgn4.CreatePolygonRgn( ptVertex4, 3, ALTERNATE);rnrn m_Crgn_flag=true;rn brA.CreateSolidBrush( RGB(192,192, 200) ); // rgnA Redrn brB.CreateSolidBrush( RGB(153,153, 153) ); // Bluern m_dcindex.FillRgn( &m_rgn1, &brA );rn m_dcindex.FrameRgn( &m_rgn1, &brB, 1, 1 );rn m_dcindex.FillRgn( &m_rgn2, &brA);rn m_dcindex.FrameRgn( &m_rgn2, &brB, 1, 1 );rn m_dcindex.FillRgn( &m_rgn3, &brA);rn m_dcindex.FrameRgn( &m_rgn3, &brB, 1, 1 );rn m_dcindex.FillRgn( &m_rgn4, &brA );rn m_dcindex.FrameRgn( &m_rgn4, &brB, 1, 1 );rn rn //输出字体rn /*CFont nunberfont1;*/rn nunberfont1.CreateFont (rn 15, // nHeightrn 0, // nWidthrn 0, // nEscapementrn 0, // nOrientationrn FW_NORMAL, // nWeightrn FALSE, // bItalicrn FALSE, // bUnderlinern 0, // cStrikeOutrn ANSI_CHARSET, // nCharSetrn OUT_DEFAULT_PRECIS, // nOutPrecisionrn CLIP_DEFAULT_PRECIS, // nClipPrecisionrn DEFAULT_QUALITY, // nQualityrn DEFAULT_PITCH | FF_SWISS, // nPitchAndFamilyrn "宋体" // lpszFacenamern ) ;rn oldFont = m_dcindex.SelectObject(&nunberfont1) ;rn m_dcindex.SetTextColor (RGB(0,0,0)) ;rn rn m_dcindex.TextOut(m_rectClient.left+/*(m_rectClient.right-m_rectClient.left)/2-strlen(m_strtitle)*4*/5,m_rectClient.top+5/*bottom-20*/,m_strtitle);rnrn //定义字体rn nunberfont.CreateFont (rn 14, // nHeightrn 0, // nWidthrn 0, // nEscapementrn 0, // nOrientationrn FW_NORMAL, // nWeightrn FALSE, // bItalicrn FALSE, // bUnderlinern 0, // cStrikeOutrn ANSI_CHARSET, // nCharSetrn OUT_DEFAULT_PRECIS, // nOutPrecisionrn CLIP_DEFAULT_PRECIS, // nClipPrecisionrn DEFAULT_QUALITY, // nQualityrn DEFAULT_PITCH | FF_SWISS, // nPitchAndFamilyrn "Times New Roman" // lpszFacenamern ) ;rn m_dcindex.SelectObject(&nunberfont) ;rn m_dcindex.SetTextColor (RGB(255,0,0)) ;rnrn// 绘制刻度,顺时针绘制rn// int i,x5,y5,x6,y6;rn// int biger_interval=4;rn int tempy=m_rectClient.top;rn int tempx=m_rectClient.right-5;rn numinterval=(m_maxvalue-m_minvalue)/biger_interval; //4 is number of biger interval rn oldPen = m_dcindex.SelectObject (&m_scalePen) ; rn rn bool pre=false;rn for (i=0;i<=m_scalenumber;i++)rn rn if (i%5==0)rn rn x5=(int)(m_centrex+(m_radii+6)*cos(1.57-m_angle/2+(m_angle/m_scalenumber)*i));rn y5=(int)(m_centrey-(m_radii+6)*sin(1.57-m_angle/2+(m_angle/m_scalenumber)*i));rn m_dcindex.MoveTo (m_centrex, m_centrey); rn m_dcindex.LineTo(x5,y5);rn rn strTemp.Format("%3.f",m_minvalue+numinterval*(biger_interval-i/5));rn if (i/5==0)rn rn if(x5+20<=m_rectClient.right && y5-15>=m_rectClient.top)rn m_dcindex.TextOut(x5,y5-14,strTemp);rn tempx=x5;rn tempy=y5-15;rn rn if (i/5==1 &&( x5+17<=tempx || y5<=tempy) )rn rn if(y5-12>=m_rectClient.top)rn m_dcindex.TextOut(x5-8,y5-14,strTemp);rn tempx=x5-8;rn tempy=y5-15;rn pre=true;rn rn elsern rn pre=false;rn rn if (i/5==2)rn rn if(pre)rn rn if(x5+15<=tempx || y5<=tempy)rn rn if(x5-26>=m_rectClient.left && y5-14>=m_rectClient.top)rn m_dcindex.TextOut(x5-10,y5-14,strTemp);rn tempx=x5-10;rn tempy=y5-14;rn pre=true;rn rn elsern rn pre=false;rn rn rn elsern rn m_dcindex.TextOut(x5-10,y5-14,strTemp);rn pre=true;rn rn rn if (i/5==3)rn rn if(pre)rn rn if(x5+13<=tempx || y5<=tempy)rn rn if(x5-26>=m_rectClient.left && y5-14>=m_rectClient.top)rn m_dcindex.TextOut(x5-12,y5-14,strTemp);rn tempx=x5-12;rn tempy=y5-14;rn pre=true;rn rn elsern rn pre=false;rn rn rn elsern rn m_dcindex.TextOut(x5-10,y5-14,strTemp);rn pre=true;rn rn rn if (i/5==4)rn rn if(x5-20>=m_rectClient.left && y5-12>=m_rectClient.top)rn m_dcindex.TextOut(x5-20,y5-12,strTemp);rn tempx=x5-20;rn tempy=y5-12;rn rn rn elsern rn x5=(int)(m_centrex+(m_radii+3)*cos(1.57-m_angle/2+(m_angle/m_scalenumber)*i));rn y5=(int)(m_centrey-(m_radii+3)*sin(1.57-m_angle/2+(m_angle/m_scalenumber)*i));rn m_dcindex.MoveTo (m_centrex, m_centrey); rn m_dcindex.LineTo(x5,y5);rn rn rn
关于书上的一段代码求解
书上的代码“rn全局类rnclass CGlobal rnrnpublic:rn CUsers curUser;rn CGlobal();rn virtual ~CGlobal();rnrn;rn因为StdAfx.h默认包含在很多程序中,所以在StdAfx.h中添加包含该全局类的头文件,在程序中直接访问curUser对象,在访问之前要要添加如下命令引入外部变量rnextern CUsers curUser;”rnrn为什么我在StdAfx.h添加头文件不成功?rn我的代码rn#include // MFC core and standard componentsrn#include // MFC extensionsrn#include // MFC Automation classesrn#include // MFC support for Internet Explorer 4 Common Controlsrnextern CUser curUser;rn#include "Global.h"rn#ifndef _AFX_NO_AFXCMN_SUPPORTrn#include // MFC support for Windows Common Controlsrn#import "c:\Program Files\Common Files\System\ADO\msado15.dll" \rnrename_namespace("ADOCG") rename("EOF", "EndOfFile") rename("BOF", "BeginOfFile")rnusing namespace ADOCG;rn//#includern//#includern//#include"icrsint.h"rnrn#endif // _AFX_NO_AFXCMN_SUPPORTrnrnextern CUsers curUser怎么用??
书上看到一段代码求解
[code=SQL]rnSET NOCOUNT ON;rnUSE temp;rnGOrnIF OBJECT_ID('dbo.T1') IS NOT NULLrn DROP TABLE dbo.T1;rnGOrnCREATE TABLE dbo.T1rn(rn keycol INT NOT NULL PRIMARY KEY,rn datacol VARCHAR(10) NOT NULLrn);rnIF OBJECT_ID('dbo.Sequence') IS NOT NULLrn DROP TABLE dbo.Sequence;rnGOrnCREATE TABLE dbo.Sequence(val INT NOT NULL);rnINSERT INTO dbo.Sequence VALUES(0);rn--创建触发器rnCREATE TRIGGER trg_T1_ioi_assign_key ON dbo.T1 INSTEAD OF INSERTrnASrnrnDECLARE @rc AS INT, @key AS INT;rnSET @rc = @@rowcount;rnrnIF @rc = 0 RETURN; -- if 0 affected rows, exitrnrn-- Update sequencernUPDATE dbo.Sequence SET @key = val, val = val + @rc;rnrnINSERT INTO dbo.T1(keycol, datacol)rn SELECT @key + ROW_NUMBER() OVER(ORDER BY const), datacolrn FROM ([color=#FF0000]SELECT 1 AS const, datacol FROM inserted[/color]) AS I;rnGOrn[/code]rn请问SELECT 1 AS const, datacol FROM inserted这句是什么意思,请解释一下,谢谢
一段有错的代码,来源于书上的
我学习java,书上有段代码,但我运行起来有错误,请高手指点哈,谢谢!rnimport java.util.*;rnrnpublic class EmployeeSortTestrnrn public static void main(String[] args)rn rn Employee[] staff=new Employee[3];rn rn staff[0]=new Employee("Harry Hacker",35000);rn staff[1]=new Employee("Carl Cracker",75000);rn staff[2]=new Employee("Tony Tester",38000);rn rn Arrays.sort(staff);rn rn for(int i=0;i
书上的一段代码,编译有问题。看看
package jxc;rnimport java.sql.*;rnpublic class UserManager rn public UserManager() rn rn static public boolean login(String strName,String strPwd) //就在这里提示错误。rn Connection conn=null;rn PreparedStatement stmt=null;rn ResultSet rs=null;rn tryrn conn=ConnectionManager.getConnection();rn stmt=conn.prepareStatement("select * from User where username=?");rn stmt.setString(1,strName);rn rs=stmt.executeQuery();rn if(rs.next())rn String strPwd2=rs.getString("Pwd");rn strPwd2.trim();rn if(!strPwd2.equals(strPwd))rn System.err.println(strName+"密码错误");rn return false;rn rn return true;rn rn elsern System.err.println(strName+"用户不存在");rn return false;rn rn rn catch(SQLException e)rn System.err.println(e);rn rn finallyrn if (rs!=null)rn tryrn rs.close();rn catch(Exception exception)rn rn if(stmt!=null)rn tryrn stmt.close();rn catch(Exception execption)rn rn if(conn!=null)rn tryrn conn.close();rn catch(Exception exception)rn rn rn rnrnrnJB X编译,错误提示:"UserManager.java": missing return statement at line 15, column 60rn怎么解决??
短小的代码,不知道错哪里了,帮我找下(新手上路,请大家多帮忙,一段书上的代码)
有如下的jsp 代码:虽然要差其他的一部分,但是它也应该可以执行,正确执行的结果应是false,但是不知道为什么报错呀。rnrn<%@ page contentType="text/html;charset=GB2312" %>rn<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>rnrnrn adfrnrnrnrnhello Adminrn rnresuot:$conditionrnrnrnrn
救命啊。帮我看看,问题出在哪里。我都弄了一天了,就是不知道问题出在哪里?
同题目!rnrnrnrn rn 用JSP访问数据库rnrn<%@ page language="java" rnimport="java.sql.*"rnimport ="java.util.*" rnimport ="java.io.*" rnimport="java.text.*" rnbuffer="20kb" rn<% rnConnection conn=null;rn tryrn Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");rn conn=DriverManager.getConnection("jdbc:odbc:student","","");rn Statement stmt=conn.createStatement();rn ResultSet rs=stmt.executeQuery("select *"+"from student");rn%>rn rn rn 学号rn 姓名rn 性别rn 年龄rn rn <% rn while(rs.next())rn rn out.println(" \n "+rs.getString("no")+"");rn out.println(" "+rs.getString("name")+"");rn out.println(" "+rs.getString("sex")+"");rn out.println(" "+rs.getString("age")+"\n");rnrn//out.print("");rnrs.close();rnrncatch(IOException ioe)rn out.println(ioe.getMessage());rnrncatch(SQLException sqle)rn out.println(sqle.getMessage());rnrncatch(ClassNotFoundException cnfe)rn out.println(cnfe.getMessage());rnrncatch(Exception e)rn out.println(e.getMessage());rnrnfinallyrn tryrn if(conn!=null)rnrnconn.close();rn rnrncatch(SQLException sqle)rnrnout.println(sqle.getMessage());rn rnrn %> rnrnrnrn
cin.getline()问题出在哪里?
#includern#includernusing namespace std;rnint main()rnrn string line;rn cin.getline(line,76));rn cout<
问题出在哪里
SELECT 编号,名称,SUM(数量) AS 数量 rnFROM 表rnGROUP BY 编号,名称rnrn用这条语句查询数据库表得出的结果还是有两条相同编号、名称的记录显示,没有实现将相同编号、名称取唯一,且数量叠加的功能
问题究竟出在哪里?
想将一个页面里的值写到另一个页面了里,加上循环就不认openwin.htm里的rn表了,问题究竟出在哪里?rnrnmain.htm:rnrn rnrnrnrnopenwin.htm:rnrnrn rnrnrnrn
求助,问题出在哪里?
我的代如下:rnimport java.awt.*;rnimport javax.swing.*;rnclass FontsPanels extends JPanel //在FontsPanels的下面有黄色波浪线,提示信息为:rn//The serializable class FontFrames does not declare a static final serialVersionUIDrn//field of type longrnrn public void paintComponent(Graphics g)rn rn String quote="当前字体.";rn Font f=new Font("华文新魏",Font.ITALIC,20);rn g.setFont(f);rn g.drawString(quote,20,20);rn rnrnclass FontFrames extends JFrame//在FontFrames的下面也有黄色波浪线,提示信息为:rn//The serializable class FontFrames does not declare a static final serialVersionUIDrn//field of type longrnrn public FontFrames()rn rn setTitle("test");rn setSize(300,200);rn Container countPane=getContentPane();rn countPane.add(new FontsPanels());rn this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);rn rnrnpublic class FontsPanelrnrn public static void main(String[] args)rn rn JFrame frame=new FontFrames();rn frame.show();rn rnrn可是执行以后窗口能够显示出来,但是窗口除了标题栏以外,JPanel是黑颜色色,什么也没有啊,这是怎么回事呢,并且在eclipse环境里面还有这样的提示信息(参见代码中的注释),而且我很奇怪,这段代码在有的人的机器上可以运行,但是有的运行时也出现了和我一样的情况,请高人指点一下
问题出在哪里?
#includern#includernrnclass Brnrn public:rn B(char *s,double n)rn rn strcpy(name,s);rn b=n;rn cout<<"Constructor\n";rn rn B() cout<<"Default\n";rn ~B() cout<<"Destructor "<
问题出在哪里?
问题一:rn 我写了一个逆序程序,但是不知道问题出在哪里.请高手指点.rn 下面程序1中在VC6下编译通过了,但是运行不了。我调试跟踪了下.运行到程序标记处就卡住了。报错为unhandled exception in reverse.exe oxC0000005 Access Violation. rnrn问题二:rn我看到网上有些人实现这样功能的程序中求指向字符串末端的指针不用库函数strlen的,比如程序2中用的while循环. 我想知道平时我们用库函数是不是能尽量不用就不要用? 还是说要去比较库函数和不用库函数的效率?如果我不知道库函数是怎么实现的不知道哪个的效率高时该如何取舍?rnrn****************************程序1.//实现字符串的逆序功能rn#include rn#include rnrnchar * reverse(char *s);rnrnvoid main()rnrnchar *s="abcdefg";rnchar *revs=reverse(s);rnprintf ("%s\n",*revs);rnrnrnchar * reverse(char *s)rnrnint i,n;rnchar * e;rnrnn=(int)strlen(s);rne=s+n;rnrnfor(i=0;i<(n/2);i++)rnrn char t;rn t=*(s+i);rn *(s+i)=*(e-i);//**这个地方运行不下去*******unhandled exception rn //in reverse.exe oxC0000005 Access Violation.rnrn *(e-i)=t;rnrnrnreturn s;rnrnrnrn****************************程序2 //对比我上面自己写的程序rn char *p="Every generation has a lengend"; rn char *q=p;char *s=p; rn while(*q)q++;q--; rn while(q>s)char c=*q;*q=*s;*s=c;q--;s++; rn rn printf("%s\n",p);rn
我的问题出在哪里?
我在WIN2K上装了SQL2K和SQL2K随带的OLAP分析工具,按照帮助的提示做了一个数据源,按照帮助建立了MOLAP的存储模式,可是在建完以后,运行数据处理时,系统提示::rn[Microsoft][ODBC 驱动程序 管理器] 未发现数据源名称并且未指定默认驱动程序;IM002; 时间:2002-2-22 9:23:29rnrn我检查了ODBC 数据源,没有问题rn我发现ODBC管理器中有两个ACCESS驱动器的版本,一个是 Microsoft Access Driverrn另一个是 to Microsoft Access Driver ,有什么分别吗?
socket问题出在哪里?
我出次使用socket,编了一个程序:rn 把客户端的操作系统版本号,处理器,内存等相关信息发送到服务器端rn并显示在服务器端的Memo中,显示时为什么它不会回车换行。rn代码如下:rn 客户端发送代码:rnvoid __fastcall TForm1::Button2Click(TObject *Sender)rnrn String buff;rnrnrn //以下是获取操作系统版本信息rn OSVERSIONINFO OSVI;rn OSVI.dwOSVersionInfoSize=sizeof(OSVERSIONINFO);rn GetVersionEx(&OSVI);rn buff=IntToStr(OSVI.dwMajorVersion)+"."+rn IntToStr(OSVI.dwMinorVersion)+"."+rn IntToStr(OSVI.dwBuildNumber)+"."+rn IntToStr(OSVI.dwPlatformId)+"."+rn OSVI.szCSDVersion;rn ClientSocket1->Socket->SendText("客户端操作系统版本信息:"+buff);rnrnrnrn//以下是获取内存信息rn MEMORYSTATUS meminfo;rn meminfo.dwLength=sizeof(MEMORYSTATUS);rn //获取内存信息rn GlobalMemoryStatus(&meminfo);rn buff=IntToStr(meminfo.dwMemoryLoad)+"%的内存在使用";rn ClientSocket1->Socket->SendText("客户端"+buff);rn buff="物理内存共有:"+IntToStr(meminfo.dwTotalPhys)+"字节";rn ClientSocket1->Socket->SendText("客户端"+buff);rn buff="虚拟内存空间大小为:"+IntToStr(meminfo.dwTotalVirtual)+"字节";rn ClientSocket1->Socket->SendText("客户端"+buff);rn buff="为使用的虚拟内存空间大小为:"+IntToStr(meminfo.dwAvailVirtual)+"字节";rn ClientSocket1->Socket->SendText("客户端"+buff);rnrnrn//系统时间rn buff=TimeToStr(Time());rn ClientSocket1->Socket->SendText("客户端当前时间:"+buff);rnrn//------------------------------------------------------------------------rnrn 服务器端接受代码:rnvoid __fastcall TForm1::ServerSocket1ClientRead(TObject *Sender,rn TCustomWinSocket *Socket)rnrn Memo1->Lines->Add(AnsiString(Socket->ReceiveText()));rnrn//---------------------------------------------------------------------------rn应该是接受一条信息就在MEMO中显示一行,下一条信息在新的一行显示的。rn为什么程序在运行时,除了操作系统版本号显示在单独一行以外,其他都rn连续显示在同一行呢?rnrn
问题出在哪里?怎么改?
class Cardrn Tag t1=new Tag(1);rn card()rn System.out.println("Card()");rn t3=new Tag(33);rn rn Tag t2=new Tag(2);rn void f()rn System.out.println("f()");rn rn Tag t3=new Tag(3);rn rn public class Wwwrn public static void main(String args[])rn card t=new Card();rn t.f();rn rn
相关热词 c++和c#哪个就业率高 c# 批量动态创建控件 c# 模块和程序集的区别 c# gmap 截图 c# 验证码图片生成类 c# 再次尝试 连接失败 c#开发编写规范 c# 压缩图片好麻烦 c#计算数组中的平均值 c#获取路由参数