summaryrefslogtreecommitdiffstats
path: root/das-java/branches/das-java-beta2/samples/customer/readme.htm
blob: 0c1f6f715d1516df561ec641a36d21e9a28014d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--
  Licensed to the Apache Software Foundation (ASF) under one
  or more contributor license agreements.  See the NOTICE file
  distributed with this work for additional information
  regarding copyright ownership.  The ASF licenses this file
  to you under the Apache License, Version 2.0 (the
  "License"); you may not use this file except in compliance
  with the License.  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an
  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  KIND, either express or implied.  See the License for the
  specific language governing permissions and limitations
  under the License.
 -->

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Tuscany DAS Sample - Customer</title>

<style>
.code {font-size: 11px; color: #006699}
.codebox {border: 1px solid #6699CC; background-color: #F1F7FA;padding:15px}
.codebox2 {border: 1px solid #6699CC; background-color: #F1F7FA;padding:15px; width:85%}
.codeboxW {border: 1px solid #6699CC; background-color: #FFFFFF;padding:15px}
.codeboxB {background-color: #C9DBED;padding:1px 10px 10px 10px}
</style>

</head>

<h1><center>Customer J2SE sample application</center></h1>

<br>

<p>
This stand-alone sample demonstrates the RDB Data Access Service in the context of a simple java application.
</p>

<br>

<h2>Building and Running</h2>

<ul>
	<li>Apache Ant latest version installed.
		<ul>
			<li>Download Apache Ant latest version on and extract into folder &lt;apache_ant_folder&gt;. You can find it here: <a href="http://ant.apache.org/bindownload.cgi">http://ant.apache.org/bindownload.cgi</a>.</li>
			<li>Add &lt;apache_ant_folder&gt;/bin directory to your OS path variable.</p></li>
		</ul>
	</li>

	<li>On console change the actual directory to &lt;tuscany_das_java_distribution&gt;/samples/customer/ and execute ant application:
	  <ul>
		<li>&lt;tuscany_das_java_distribution&gt;/samples/customer/&gt; ant</li>
	  </ul>
	</li>
</ul>

<p>
The sample will run and output the following:
</p>

<p>
<pre style="code">
Buildfile: build.xml

run:
     [java] ************* Initializing database *************
     [java] ** DB type  : derby
     [java] ** Database : jdbc:derby:target/dastest; create = true
     [java] ** User     :
     [java] ** Password :
     [java] ************************************************
     [java] Setting up for derby run!
     [java] Dropping tables
     [java] Dropping procedures
     [java] Creating tables
     [java] Creating procedures
     [java] Inserting data in tables
     [java] Database setup complete!
     [java]
     [java] Result:select all customers
     [java]    ID:1 LASTNAME:John ADDRESS:USA
     [java]    ID:2 LASTNAME:Amita ADDRESS:INDIA
     [java]    ID:3 LASTNAME:Patrick ADDRESS:UK
     [java]    ID:4 LASTNAME:Jane ADDRESS:UN
     [java]
     [java] Result:insert new customer
     [java]    ID:1 LASTNAME:John ADDRESS:USA
     [java]    ID:2 LASTNAME:Amita ADDRESS:INDIA
     [java]    ID:3 LASTNAME:Patrick ADDRESS:UK
     [java]    ID:4 LASTNAME:Jane ADDRESS:UN
     [java]    ID:5 LASTNAME:Jenny ADDRESS:USA
     [java]
     [java] Result:update first customer
     [java]    ID:1 LASTNAME:BlueBerry ADDRESS:USA
     [java]    ID:2 LASTNAME:Amita ADDRESS:INDIA
     [java]    ID:3 LASTNAME:Patrick ADDRESS:UK
     [java]    ID:4 LASTNAME:Jane ADDRESS:UN
     [java]    ID:5 LASTNAME:Jenny ADDRESS:USA
     [java]
     [java] Result:delete last customer
     [java] Deleting customer named: Jenny
     [java]    ID:1 LASTNAME:BlueBerry ADDRESS:USA
     [java]    ID:2 LASTNAME:Amita ADDRESS:INDIA
     [java]    ID:3 LASTNAME:Patrick ADDRESS:UK
     [java]    ID:4 LASTNAME:Jane ADDRESS:UN

BUILD SUCCESSFUL
</pre>
</p>

<br>

<p>
<b>Observation:</b>The build.xml ant file only works on DAS Java binary distribution.
</p>



<h2>Running  Sample with MySQL</h2>
<br>
<p>
The sample is pre-configured to run using an embedded Derby database.Follow below instructions to run the sample on another database (e.g MySQL).<br>
</p>

<ul>
   <li>Expand sample-customer.jar under <tuscany_das_java_distribution>/samples/customer to access CustomersConfig.xml</li>
   <li>Change CustomersConfig.xml - comment Derby connection info and uncomment MySQL connection info. Check for correct userName, password, and other configuration information </li>
   <li>Change <tuscany_das_java_distribution>/samples/customer /build.xml to replace pathelement location from Derby jar to MySQL jar like -
      <ul>
         <li>&lt;pathelement location="mysql-connector-java-5.0.4.jar"/&gt;</li>
      </ul>
   </li>
   <li>Create new sample-customer.jar to use the changed CustomersConfig.xml , replacing the one from binary distribution under <tuscany_das_java_distribution>/samples/customer.</li>
   <li>Place required mysql jar (e.g. mysql-connector-java-5.0.4.jar) under <tuscany_das_java_distribution>/samples/customer.</li>
   <li>From command prompt run the sample application using ant -
      <ul>
         <li>&lt;tuscany_das_java_distribution>/samples/customer/&gt; ant</li>
      </ul>
   </li>
 </ul>

<p>
<b>Observations:</b>
<ul>
   <li>These instructions apply only for DAS Java binary distribution.</li>
   <li>MySQL Database will be created and populated with necessary structure and data if not present</li>
</ul>

</BODY>
</HTML>