<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應用程序站點

    優選博客

    主站蜘蛛池模板: 免费在线看污视频| 成人午夜免费视频| 91九色精品国产免费| 337p日本欧洲亚洲大胆精品555588| 国产一精品一AV一免费| 亚洲AV永久青草无码精品| 国产情侣久久久久aⅴ免费| 亚洲国产精品无码久久一线| 日本免费中文字幕| 亚洲色av性色在线观无码| av无码国产在线看免费网站| 亚洲三级视频在线观看| 成年女人色毛片免费看| 看免费毛片天天看| 国内精品99亚洲免费高清| 中国人免费观看高清在线观看二区| 亚洲综合AV在线在线播放| 久久青草免费91观看| 亚洲人成在线中文字幕| 四虎成人免费观看在线网址| 日韩在线观看免费| 精品久久久久久亚洲| 国产成人精品免费视频大| 亚洲av日韩综合一区二区三区| 亚洲JIZZJIZZ中国少妇中文| 在线观看免费视频一区| 亚洲国产美女视频| 免费国产在线观看老王影院| 成人片黄网站色大片免费观看APP| 亚洲蜜芽在线精品一区| 免费在线看片网站| 久久免费看少妇高潮V片特黄| 亚洲午夜电影在线观看| 亚洲A∨精品一区二区三区| 国产精品免费观看调教网| 亚洲日本va一区二区三区| 亚洲精品无码久久一线| 国产成人免费爽爽爽视频| 一区二区三区无码视频免费福利| 亚洲AV无码久久久久网站蜜桃| 亚洲人午夜射精精品日韩|