Windows10 IIS の設定

IIS の有効化

PHP を使用する為に必要なチェックですが、ASP も動作するようにしています。



IIS マネージャーのショートカットの作成

インターネット インフォメーション サービス (IIS) マネージャーのショートカットは、メニューの以下の位置のアイコンを右クリックで『その他』=>『ファイルの場所を開く』でショートカットがあるので、コピーでデスクトップに置きます



php.ini の設定

PHP: Microsoft IIS 7.0 以降 - Manual

一番重要なのは、cgi.force_redirect = 0 の設定です。他はおそらくデフォルト値だと思います( ですが、一応明示設定するほうがいいでしょう )

php の登録

以下の画像の手順で、PHP を登録します。これらは全て PHP のサイトにある Microsoft IIS 7.0 以降 の説明と同じです。









アプリケーションの追加

ASP を使わないで、PHP だけで利用する場合は 『仮想ディレクトリの追加』でかまいません。( global.asa を使用する場合に、アプリケーションの追加を実行します。)







▼ デフォルドでは WEB のディレクトリ一覧が表示されないので、ディレクトリ表示を有効にします。






IIS のバージョンの確認方法



ASP でエラーを表示する

デフォルトでは、エラーが起きるとブラウザのエラーページが表示されます。ASP の具体的なエラーをブラウザに出力するには、設定が必要です。



32ビットの環境で ASP を実行する為の設定

ASP では COM を使用します。その場合、64ビットのものが存在しない事が多いので、基本32 ビットで動作するようにします。





../ という相対パスを有効にする

セキュリティ上の理由により、デフォルトでは相対パスで親フォルダへのアクセスを禁じていますが、そもそも IIS はイントラネットでしょうし、設定しておいたほうが良い環境がほとんどでしょう。




インストール, 設定

Pleiades Eclipse 4.7 Oxygen : SWT(Table) + MySQL の SQL(SELECT) で一覧表示



WindowBuilder のインストール

SWT と Swing に関しては、WindowBuilder のサイト よりインストール用の URL を取得します。

※ バージョンは、WindowBuilder のバージョンです。(Eclipse のバージョンに依存しなくなりました)

この URL を『新規ソフトウェアのインストール』で表示されるダイアログに入力します


以前の WindowBuilder のアンインストールは、『ヘルプメニュー』>『Eclipse について』>『インストール詳細』で表示されるウインドウからアンインストールします

プロジェクト作成

プロジェクトは専用のものを使いますので、『その他』から以下を選択して下さい。

プロジェクトを作成したら、CTRL+N でその他より、以下を選択して下さい。

実行してウインドウが表示されたら準備完了です。

テンプレートの修正

メニューバー・タスクバー・ツールバー用のテンプレートは邪魔なだけなので削除します。

MySQL 接続用ライブラリのインストール

Download Connector/J から jar をダウンロードして使用するか、Maven Repository より pom.xml に記述する内容を取得して使用します。

バージョンは、ここでは 5.1.46 を使用しています
( ダウンロードページでは、Looking for previous GA versions? リンクをクリックします )

Maven を使用するには、既存のプロジェクトを変換するのが簡単です。
( プロジェクトを右クリックして『構成』から Maven プロジェクトへの変換 )

Chapter 4 Connector/J Examples

実行ソースコード

001.package mysql;
002. 
003.import java.sql.DriverManager;
004.import java.sql.ResultSet;
005.import java.sql.SQLException;
006.import java.text.SimpleDateFormat;
007. 
008.import org.eclipse.jface.window.ApplicationWindow;
009.import org.eclipse.swt.SWT;
010.import org.eclipse.swt.events.SelectionAdapter;
011.import org.eclipse.swt.events.SelectionEvent;
012.import org.eclipse.swt.graphics.Point;
013.import org.eclipse.swt.widgets.Button;
014.import org.eclipse.swt.widgets.Composite;
015.import org.eclipse.swt.widgets.Control;
016.import org.eclipse.swt.widgets.Display;
017.import org.eclipse.swt.widgets.Shell;
018.import org.eclipse.swt.widgets.Table;
019.import org.eclipse.swt.widgets.TableColumn;
020.import org.eclipse.swt.widgets.TableItem;
021. 
022.import com.mysql.jdbc.Connection;
023.import com.mysql.jdbc.ResultSetMetaData;
024.import com.mysql.jdbc.Statement;
025. 
026.public class Main extends ApplicationWindow {
027. 
028.        // https://help.eclipse.org/neon/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fapi%2Findex.html&org/eclipse/swt/widgets/Table.html
029.        private Table table;
030. 
031.        // https://mvnrepository.com/artifact/mysql/mysql-connector-java/5.1.46
032.        // https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-examples.html
033.        private Connection conn = null;
034.        private Statement stmt = null;
035.        private ResultSet rs = null;
036.        private int maxRows = 20;
037. 
038.        public Main() {
039.                super(null);
040.                createActions();
041.        }
042. 
043.        @Override
044.        protected Control createContents(Composite parent) {
045.                Composite container = new Composite(parent, SWT.NONE);
046. 
047.                table = new Table(container, SWT.BORDER | SWT.FULL_SELECTION);
048.                table.setBounds(10, 41, 764, 338);
049.                table.setHeaderVisible(true);
050.                table.setLinesVisible(true);
051. 
052.                Button button = new Button(container, SWT.NONE);
053.                button.addSelectionListener(new SelectionAdapter() {
054.                        @Override
055.                        public void widgetSelected(SelectionEvent e) {
056.                                // 行を全て削除
057.                                table.removeAll();
058.                                loadMySQL("select * from 社員マスタ");
059.                        }
060. 
061.                });
062.                button.setBounds(10, 10, 75, 25);
063.                button.setText("実行");
064. 
065.                return container;
066.        }
067. 
068.        private void createActions() {
069.                // Create the actions
070.        }
071. 
072.        public static void main(String args[]) {
073.                try {
074.                        Main window = new Main();
075.                        window.setBlockOnOpen(true);
076.                        window.open();
077.                        Display.getCurrent().dispose();
078.                } catch (Exception e) {
079.                        e.printStackTrace();
080.                }
081.        }
082. 
083.        @Override
084.        protected void configureShell(Shell newShell) {
085.                super.configureShell(newShell);
086.                newShell.setText("MySQL Connector/J");
087.        }
088. 
089.        @Override
090.        protected Point getInitialSize() {
091.                return new Point(800, 443);
092.        }
093. 
094. 
095.        private void loadMySQL( String sql ) {
096. 
097.                try {
098.                        // MySQL Connector/J 接続
099.                        conn = (Connection) DriverManager.getConnection(
100.                                "jdbc:mysql://localhost/lightbox?user=root&password="
101.                        );
102. 
103.                        stmt = (Statement) conn.createStatement();
104.                        rs = stmt.executeQuery(sql);
105. 
106.                        // select の結果の列情報の取得
107.                        ResultSetMetaData rsmd = (ResultSetMetaData) rs.getMetaData();
108. 
109.                        // 列数
110.                        int columnCount = rsmd.getColumnCount();
111. 
112.                        // 前回のテーブル列を全て削除
113.                        int tableColumnCount = table.getColumnCount();
114.                        TableColumn tableColumnWork = null;
115.                        for( int i = tableColumnCount - 1; i >= 0; i--) {
116.                                tableColumnWork = table.getColumn(i);
117.                                tableColumnWork.dispose();
118.                        }
119. 
120.                        // 列名
121.                        TableColumn tableColumn = null;
122.                        for( int i = 1; i <= columnCount; i++) {
123.                                tableColumn = new TableColumn(table, SWT.NONE);
124.                                tableColumn.setWidth(100);
125.                                tableColumn.setText(rsmd.getColumnName(i));
126.                        }
127. 
128.                        TableItem tableItem = null;
129.                        SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
130.                        int countRow = 0;
131.                        while( rs.next() && countRow < maxRows ) {
132. 
133.                                countRow++;
134. 
135.                                String[] columnData = new String[columnCount];
136. 
137.                                for( int i = 1; i <= columnCount; i++) {
138. 
139.                                        if ( rsmd.getColumnTypeName(i).equals("DATETIME") ) {
140.                                                columnData[i-1] = sdf.format(rs.getDate(i));
141.                                        }
142.                                        else {
143.                                                columnData[i-1] = rs.getString(i);
144.                                        }
145. 
146.                                }
147.                                tableItem = new TableItem(table, SWT.NONE);
148.                                tableItem.setText(columnData);
149.                        }
150. 
151.                        rs.close();
152.                        stmt.close();
153.                        conn.close();
154. 
155.                } catch (SQLException ex) {
156.                        // handle any errors
157.                        System.out.println("SQLException: " + ex.getMessage());
158.                        System.out.println("SQLState: " + ex.getSQLState());
159.                        System.out.println("VendorError: " + ex.getErrorCode());
160.                }
161. 
162.        }
163.}

pom.xml
01.<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
02.  <modelVersion>4.0.0</modelVersion>
03.  <groupId>MySQL_01</groupId>
04.  <artifactId>MySQL_01</artifactId>
05.  <version>0.0.1-SNAPSHOT</version>
06.  <build>
07.    <sourceDirectory>src</sourceDirectory>
08.    <plugins>
09.      <plugin>
10.        <artifactId>maven-compiler-plugin</artifactId>
11.        <version>3.7.0</version>
12.        <configuration>
13.          <source>1.8</source>
14.          <target>1.8</target>
15.        </configuration>
16.      </plugin>
17.    </plugins>
18.  </build>
19.  <dependencies>
20.    <dependency>
21.      <groupId>mysql</groupId>
22.      <artifactId>mysql-connector-java</artifactId>
23.      <version>5.1.46</version>
24.    </dependency>
25.  </dependencies>
26. 
27.</project>

関連する記事

WindowBuilder のテーブルコントロールにインターネットから JSON データを読み込んで処理するテンプレート ( 行データをダブルクリックして取得 )




C# アプリケーション作成のトピック

DataGridView ( FORM アプリ )

C# : Excel を データベースとして DataGridView に読み込む
DataTable をレコードセットから作成して、DataSource に設定する最も簡易なパターン

C# : Microsoft Access のテーブルとビューの一覧と任意の SQL を実行するテンプレート


▼ 列を自分で作成
Microsoft Access に対してSQLを入力してその結果を DataGridView に表示する最も簡単なコード
(※ テーブル・ビュー一覧を GetOleDbSchemaTable で作成)


メール ( FORM アプリ )

VS2010(C#) : TKMP.DLLを使った、メール送信テンプレート

(C#) / VS2010 または VS2012 : TKMP.DLL(3.1.2 または 3.1.8)を使った、『さくらインターネット』用メール送信テンプレート


データベース

System.Data.OleDb で select into 構文を使って簡単に Microsoft Access のデータを他の データベースにエクスポートする

C# : System.Data.OleDb で Microsoft Access のデータを読み取る

VS2010(C#) : System.Data.Odbc データ取得(SELECT)処理( MySQL )

VS2010(C#) : データベースを System.Data.Linq.DataContext で読み込んでからの LINQ

WPF(C#) : ExecuteQuery を使って、DataGrid に自動的に select 構文の結果を表示する


COM

C# : dynamic 型 による Excel へのアクセス

C#(VS2010) : dynamic 型を使用して CreateObject と同等に Scripting.FileSystemObject を使用する

VS2010(C#) : COMの Msxml2.ServerXMLHTTP を使用して WEBアプリにバイナリデータを POST する


DataGrid ( WPF アプリ )

VS(C#) : DataGrid に バインドを使用して JSON データの配列を表示する( Json.NET を使用 )

VS2010 WPF(C#) DataGrid + データベース バインド / DataGrid に MDB のデータを読み込んで表示するテンプレート

WPF(C#) : 『DataGrid に、TKMP.DLL を使用して非同期にメールヘッダを受信する』 テンプレート

WPF(C#) : 『DataGrid に、バインド用クラスを使って自動的にカラムと行を生成する』 テンプレート

WPF アプリケーション(VS2010/C#) の Window 間の扱いを知る為のテンプレート

XAML の 各属性を別の行に配置する Visual Studio の設定


DXライブラリ

C# でDXライブラリを使って簡単なシューティングをクラス化して標準化 / メインループとプレイヤー (4)

C# でDXライブラリを使って簡単なシューティングをクラス化して標準化 / メインループとプレイヤー (3)

C# でDXライブラリを使って簡単なシューティングをクラス化して標準化 / メインループとプレイヤー (2)

C# でDXライブラリを使って簡単なシューティングをクラス化して標準化 / メインループとプレイヤー (1)

C# でDXライブラリを使って簡単なシューティング部分を作るサンプル


特殊

iText( itextsharp-all-5.4.3 / C# ) で簡単に PDF 出力をする。

アプリケーションテスト用コンソールアプリ(TryApp)テンプレート

TryAppテンプレートを使って『The Zip, GZip, BZip2 and Tar Implementation For .NET』のテスト

VS2010 Formアプリ(C#) : 通知領域で常駐し、ブラウザのフォームからデータを取得する HttpServer テンプレート

VS2012 Formアプリ(C#) : 通知領域で常駐する HttpServer テンプレート

Framework4.5(C#) のコンソールアプリケーションで、とても簡単に HTTP サーバーを作成できます

Framework4(C#) : WebClient で Post と Get する汎用 static クラス

VS(C#) : Json.NET を使用して文字列形式の JSON をプログラムで参照する具体的な方法

C# コンソールアプリを AN HTTP で実行




Oracle 関連

Oracle は、Oracle 11g (32ビット) です。

Oracle 11g 学習環境の作成 : SQLPlus の環境作成

Oracle SQLPlusスキーマの作成
1.create tablespace STUDY
2.datafile 'C:\APP\LIGHTBOX\ORADATA\ORCL\STUDY.DBF'
3.        size 5M
4.        autoextend on
5.        next 1M
6.        maxsize unlimited
7.segment space management AUTO;

Oracle に学習用DB の 販売管理C.mdb をインポートする


※ SQL の窓 オンラインヘルプ