Examples of using java Application and JSP to call javaBean

Source: Internet
Author: User
Tags getmessage odbc stmt
// Java bean
// File name: faq. java
Import java. SQL .*;
Public class faq {
String sDBDriver = "sun. jdbc. odbc. JdbcOdbcDriver ";
String sConnStr = "jdbc: odbc: faq ";
Connection conn = null;
ResultSet rs = null;
Public faq (){
Try {
Class. forName (sDBDriver );
} Catch (java. lang. ClassNotFoundException e ){
System. err. println ("faq ():" + e. getMessage ());
    }
}
Public ResultSet executeQuery (String SQL ){
Rs = null;
Try {
Conn = DriverManager. getConnection (sConnStr );
Statement stmt = conn. createStatement ();
Rs = stmt.exe cuteQuery (SQL );
} Catch (SQLException ex ){
System. err. println ("aq.exe cuteQuery:" + ex. getMessage ());
        }
Return rs;
    }
}
// Java Application
// File name: testfaq. java
Import java. SQL .*;
Class getRs
{
Public static String Answer;
Public static String Subject;
Public static String [] [] rsArray = new String [9] [2];
Public static int n = 0;
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.