3

私はプログラミングにとても慣れていないので、ご容赦ください。最初は意味がわからない場合は、事前にお詫び申し上げます...!

私は学部のプログラミングプロジェクトを行っており、Javaプログラム内にいくつかのデータベースを作成する必要があります。私はEclipse(galilo)を使用してプログラムを作成しています。私はconnector/Jをダウンロードしましたが、それをどのように使用すべきか最も霧がかかっていません!

ステップバイステップのアプローチを私に与えることができる人はいますか?!

どうもありがとう!

4

2 に答える 2

4

Eclipse内で何らかのデータエクスプローラーが必要な場合は、上記のリンク、より具体的にはプラグインのドキュメントを参照してください。

OTOH、JDBCを使用してmysqlデータベースに接続する方法を知りたい場合は、以下のコードサンプルで説明されています。

Connection connection = null;
        try {
            //Loading the JDBC driver for MySql
            Class.forName("com.mysql.jdbc.Driver");

            //Getting a connection to the database. Change the URL parameters
            connection = DriverManager.getConnection("jdbc:mysql://Server/Schema", "username", "password");

            //Creating a statement object
            Statement stmt = connection.createStatement();

            //Executing the query and getting the result set
            ResultSet rs = stmt.executeQuery("select * from item");

            //Iterating the resultset and printing the 3rd column
            while (rs.next()) {
                System.out.println(rs.getString(3));
            }
            //close the resultset, statement and connection.
            rs.close();
            stmt.close();
            connection.close();
        } catch (SQLException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
于 2010-03-18T10:37:34.757 に答える