You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> Once done, unzip the .crate file which is actually a .tar.gz.
32
-
>
33
-
> Copy the setup.rs from "examples" folder to your RUST project under examples folder.
34
-
>
35
-
> Add the below dependencies in case not present:
36
-
```
37
-
[build-dependencies]
38
-
cc = "1.0"
39
-
winapi = "0.2"
40
-
user32-sys = "0.2"
41
-
sys-info = "0.7.0"
42
-
bitness = "0.4.0"
43
-
error-chain = "0.12.4"
44
-
tempfile = "3.1.0"
45
-
reqwest = "0.10.10"
46
-
tokio = { version = "0.2", features = ["full"] }
47
-
futures = "0.3.8"
48
-
zip = "0.5"
49
-
flate2 = "1.0"
50
-
tar = "0.4"
51
-
52
-
[dependencies]
53
-
winapi = "0.2"
54
-
user32-sys = "0.2"
55
-
sys-info = "0.7.0"
56
-
bitness = "0.4.0"
57
-
error-chain = "0.12.4"
58
-
tempfile = "3.1.0"
59
-
reqwest = "0.10.10"
60
-
tokio = { version = "0.2", features = ["full"] }
61
-
futures = "0.3.8"
62
-
zip = "0.5"
63
-
flate2 = "1.0"
64
-
tar = "0.4"
65
-
odbc-safe = "0.5.0"
66
-
odbc-sys = "0.8.2"
67
-
log = "0.4.1"
68
-
encoding_rs = "0.8.14"
69
-
prettytable-rs = "^0.8"
70
-
lazy_static = "1.0"
71
-
r2d2 = "0.8"
72
22
```
73
-
>
74
-
> Now, run the below command once you have followed the above steps and CLI Driver will be installed:
75
-
```
76
-
cargo run --package <package name i.e. ibm_db or <your package name>> --example setup
23
+
$ curl https://sh.rustup.rs -sSf | sh
24
+
$ source ~/.bashrc
25
+
26
+
$ cargo --version
27
+
$ rustc --version
28
+
$ git --version
77
29
```
78
30
79
-
> Then you can do "cargo install --path ." from ibm_db crate or "cargo install ibm_db" or simply include the "ibm_db" driver in your cargo.toml depending on your convenience.
31
+
#### Install **clidriver**.
80
32
81
-
#### NOTE:
33
+
<pre>
34
+
<b>$ cargo install ibm_db --example setup</B>
82
35
83
-
In order for the test/db program to run, DSN needs to be configured.
84
-
Update the db2dsdriver.cfg file(present in /clidriver/cfg folder under CLI driver path) with the requisite details.
let sql_text = "select current server from sysibm.dual";
116
+
117
+
match stmt.exec_direct(&sql_text)? {
118
+
Data(mut stmt) => {
119
+
let cols = stmt.num_result_cols()?;
120
+
while let Some(mut cursor) = stmt.fetch()? {
121
+
for i in 1..(cols + 1) {
122
+
match cursor.get_data::<&str>(i as u16)? {
123
+
Some(val) => print!(" {}", val),
124
+
None => print!(" NULL"),
125
+
}
126
+
}
127
+
println!();
128
+
}
129
+
}
130
+
NoData(_) => println!("Query executed, no data returned"),
131
+
}
132
+
133
+
Ok(())
134
+
}
122
135
```
123
136
137
+
#### Build and run the program
138
+
139
+
<pre>
140
+
<b>$ cd ~/testdb
141
+
$ cargo build</b>
142
+
... more ...
143
+
Compiling testdb v0.1.0 (/home/admin/testdb)
144
+
Finished dev [unoptimized + debuginfo] target(s) in 0.44s
145
+
146
+
<b>$ ./target/debug/testdb</b>
147
+
148
+
Connection successful.
149
+
TESTDB
150
+
Success.
151
+
</pre>
152
+
153
+
You successfully tested the Rust program for connecting to the RDS Db2.
154
+
124
155
### <aname="Licenserequirements"></a> License requirements for connecting to databases
125
156
126
157
rust_ibm_db driver can connect to DB2 on Linux Unix and Windows without any additional license/s, however, connecting to databases on DB2 for z/OS or DB2 for i(AS400) Servers require either client side or server side license/s. The client side license would need to be copied under `license` folder of your `clidriver` installation directory and for activating server side license, you would need to purchase DB2 Connect Unlimited for System z® and DB2 Connect Unlimited Edition for System i®.
@@ -131,29 +162,8 @@ To know more about server based licensing viz db2connectactivate, follow below l
131
162
*[Activating the license certificate file for DB2 Connect Unlimited Edition](https://www.ibm.com/developerworks/community/blogs/96960515-2ea1-4391-8170-b0515d08e4da/entry/unlimited_licensing_in_non_java_drivers_using_db2connectactivate_utlility1?lang=en).
132
163
*[Unlimited licensing using db2connectactivate utility](https://www.ibm.com/developerworks/community/blogs/96960515-2ea1-4391-8170-b0515d08e4da/entry/unlimited_licensing_in_non_java_drivers_using_db2connectactivate_utlility1?lang=en.)
133
164
134
-
### How to run sample program:
135
-
136
-
To run the sample i.e. **main.rs** simply execute:-
137
-
138
-
```
139
-
cargo run
140
-
```
141
-
#### You can also run other Sample Programs under examples folder using:
142
-
```
143
-
cargo run --package ibm_db --example <example_name i.e. connect or list_tables etc.>
144
-
e.g. cargo run --package ibm_db --example connect
145
-
```
146
-
## NOTE for MACOS:
147
-
If you get an error i.e. "dyld: Library not loaded: libdb2.dylib"
148
-
Run the following command(Where replace the <RUST_CRATE_LIB> with the path of your rust program root folder):
0 commit comments