<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    T his exaple using JDBC-ODBC bridge drive program.Using table NorthwindTest.
    NorthwindTest.java

    package skyey.snow;
    import java.sql.*:

    /** A JDBC example that connects to the Microsoft Acess sample Northwind database,issues a simple SQL query to the
    ? *??employee table, and prints the results.
    */

    public class NorthwindTest {
    ??? public static void main(String[] args)
    ??? {
    ??????? String driver="sun.jdbc.odbc.JdbcOdbcDriver";
    ??????? String url="jdbc:odbc:Northwind";
    ??????? String username=""; //No username/password required
    ??????? String password=""; //for desktop access to MS Access.
    ??????? showEmployeeTable(driver,url,username,passwrd);
    ???????
    ??????? /** Query the employee table and print the first and
    ???????? *? last names.
    ???????? */

    ??????? public static void showEmployeeTable(String driver,String url,String username,String password)
    ??????? {
    ??????????? try
    ??????????? {
    ??????????????? //load database driver if it's not already loaded.
    ??????????????? Class.forName(driver);
    ??????????????? //Establish network connection to database.
    ??????????????? Connection connection=
    ??????????????????????? DriverManager.getConnection(url,username,password);
    ??????????????? System.out.println("Employees\n"+"=============================");
    ??????????????? //Create a Statement for executing queries.
    ??????????????? Statement statement=connection.clearWarnings();
    ??????????????? String query=
    ??????????????????????? "select firstName,lastName form employee";
    ??????????????? //send query to database and store results.
    ??????????????? ResultSet resultSet=statement.executeQuery(query);
    ??????????????? //print results.
    ??????????????? while(resultSet.next())
    ??????????????? {
    ??????????????????? System.out.println(resultSet.getString("firstName")+"");
    ??????????????????? System.out.println(resultSet.getString("lastName")+"");
    ??????????????? }
    ??????????????? connection.close();
    ??????????? }
    ??????????? catch(ClassNotFoundException e)
    ??????????? {
    ??????????????? System.err.println("Error loading driver:"+e);
    ??????????? }
    ??????????? catch(SQLException e1)
    ??????????? {
    ??????????????? System.err.println("Error with connection:"+e1);
    ??????????? }
    ??????? }
    ??? }
    }

    from example we should konw how to write a simpleness class for Database connection,and in this example i find a very good method we should study that is we should connection two or much more class using :
    public class NorthwindTest {
    ??? public static void main(String[] args)
    ??? {
    ??????? String driver="sun.jdbc.odbc.JdbcOdbcDriver";
    ??????? String url="jdbc:odbc:Northwind";
    ??????? String username=""; //No username/password required
    ??????? String password=""; //for desktop access to MS Access.
    ??????? showEmployeeTable(driver,url,username,passwrd);
    ???????
    ??????? /** Query the employee table and print the first and
    ???????? *? last names.
    ???????? */

    ??????? public static void showEmployeeTable(String driver,String url,String username,String password)
    ??????? {}
    if we do like this our codes will became short,simpleness and beautiful.
    posted on 2006-04-09 10:42 飛揚 閱讀(287) 評論(0)  編輯  收藏 所屬分類: Sound Code

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     

    統計

    FAQ網站

    JSP/Java/Servlet開發工具

    JSP/Java/Servlet技術著名網站

    JSP/Servlet應用程序站點

    優選博客

    主站蜘蛛池模板: 国产精品成人无码免费| 99视频在线精品免费观看6| 国产精品亚洲产品一区二区三区| 春暖花开亚洲性无区一区二区| 四虎国产精品免费久久| 亚洲AV无码乱码在线观看代蜜桃| 999久久久免费精品国产| 亚洲国产精品日韩在线| 国产卡二卡三卡四卡免费网址| 亚洲手机中文字幕| 成人性生交大片免费看无遮挡 | 亚洲成A人片在线观看无码不卡 | 黄色成人免费网站| 国产亚洲福利在线视频| 日本成人免费在线| 亚洲码一区二区三区| 性短视频在线观看免费不卡流畅 | 亚洲国产精品综合久久一线 | 国产精品九九久久免费视频| 亚洲中文无韩国r级电影| 皇色在线免费视频| 国产成人无码免费视频97 | 久久国产精品2020免费m3u8| 亚洲电影免费在线观看| AV无码免费永久在线观看| 亚洲情A成黄在线观看动漫软件| 美女被免费视频网站a国产 | 成在线人直播免费视频| 国产亚洲精品自在久久| 亚洲最大免费视频网| 青草久久精品亚洲综合专区| 国产亚洲精品福利在线无卡一| 91精品导航在线网址免费| 亚洲va中文字幕| 亚洲爆乳无码一区二区三区| 四虎永久在线精品免费观看视频| 精品亚洲福利一区二区| 久久精品国产精品亚洲艾| 四虎www免费人成| 久久久久国色av免费看| 相泽南亚洲一区二区在线播放|