2013年11月4日星期一

Neighborhoods : jsp to connect sql server, netbeans suggesting no statement such as the class name

My setup is this:
1, windows of ClassPath has been added to my sqljdbc4.jar
2, the project's library which adds sqljdbc4.jar
3, sqljdbc_auth.dll files to widows \ system32 following the
4, import java.sql. * also added .
5, are connected to a sql server 2005, using netbeans 7.3.1. In netbeans Services - > Databases , there is the ability to get on the connection . Authentication mode to Mixed Mode . Port number 1433.
but ide still prompt a lot of mistakes , as shown:
class.forname see documentation says that one can not write it. But commenting is wrong is the same
error message is : unreported exception SQLexception; must be caught or declared to be thrown
Although prompted various errors , but the grammar tips are effective , whether or Statement DriverManager object , enter the code when prompted to have a variety of properties and methods .
seeking advice. Internet looking for a day , writing basically like this.

------ Solution ------------------------------------ --------
halo so obvious that you did not understand ?

block to be processed there sqlexception

else or else write try catch block in the method definition that throw out
------ Solution --------- -----------------------------------
is best to put the program into the try-catch , the but do not catch the exception in the catch , the catch the exception thrown, otherwise things generally declared in a service layer , you can not roll back , dao layer error could not find
------ For reference only --- ------------------------------------
means that this block must try .. do ? I just tested it. . . There is, I see a variety of other people's code, it is not a lot here, try to write and direct such use, others can ah.
------ For reference only -------------------------------------- -


write error test must be addressed or else the same way

others may just write a sample code does not address the specific details
------ For reference only ----------------- ----------------------


try if you do not want to write it in the method definition , then ioexception the sqlexception throw out
------ For reference only ---------- -----------------------------
I Yune , buy the book which is not written. . . This is not what harm us newcomers . .
Thank you for your advice. csdn is really a good place. Search for a day can not solve, to 10 minutes to get here .

没有评论:

发表评论