Home > Back-end >  Java database link Statement why there is the close method?
Java database link Statement why there is the close method?

Time:03-22

Import the Java. Beans. The Statement;
Import the Java. SQL. Connection;
Import the Java. SQL. DriverManager;
Public class lalala {
Public static void main (String [] args) {
The Connection of ct=null;//link
The Statement sm=null;//declare
Try {
Class.forname (" sun. JDBC. Odbc. JdbcOdbcDriver ");//load driver
Ct=DriverManager. GetConnection (" JDBC: odbc: mysqlodbc ", "root", "378676531");//the data source name; Account name; Password

} the catch (Exception e) {}
The finally {
Try {
If (sm!=null) {
Sm. Close;// this place complains
}
If (ct!!!=null) {
Ct. The close ();
}
} the catch (Exception e2) {}
}
}
}

CodePudding user response:

Sm. Close;//this place complains

Why no brackets, isn't it should be a close ()

CodePudding user response:

What's wrong? Error posted to "suit the remedy to the case"

CodePudding user response:

Sm. Close to sm. The close ()

CodePudding user response:

As long as it's function to bracket

CodePudding user response:

Isn't the problem the parentheses is sm. Not after the close () method
  • Related