| |

VerySource

 Forgot password?
 Register
Search
View: 819|Reply: 3

Ask a problem with the definition of variables, hurry! !! !!

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 Invalid IP Address

Post time: 2020-3-13 23:00:01
| Show all posts |Read mode
package com.mingri.info;

import com.mingri.dbconn.DBResult;
package com.mingri.info;

import java.sql. *;

public class KhRegist {
  private KhinfoBean khinfo;
  DBResult rst = new DBResult ();
  
  public void setKhinfo (KhinfoBean khinfo) {
    
    this.khinfo = khinfo;
  }
...
This code appears this error "KhRegist.java": unreported exception java.lang.Exception; must be caught or declared to be thrown at line 8, column 16, the problem lies in DBResult rst = new DBResult (); please master how solve! Anxious!
Reply

Use magic Report

1

Threads

51

Posts

32.00

Credits

Newbie

Rank: 1

Credits
32.00

 China

Post time: 2020-6-13 10:00:01
| Show all posts
try{
DBResult rst=new DBResult();
}catch(Exception e){}
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-7-18 21:00:01
| Show all posts
This means that there is an exception in your program that has not been caught and handled.
Remove the new DBResult() statement from the declared code.
Then add the following statement in the construction method:

try{
rst=new DBResult();
}catch(Exception e){}
or
After writing rst=new DBResult(); into the construction method, declare possible exceptions after the construction method.
Such as:
KhRegist() throws Exception {
    ...
    rst=new DBResult();
    ...
}
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-12 11:45:01
| Show all posts
"KhRegist.java": unreported exception java.lang.Exception; must be caught or declared to be thrown at line 8, column 16,
An exception is thrown and needs to be caught
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list