JetOS93 MySQL SDK User Manual www.korenix.com 0.0.1 Korenix Overview 1
Copyright Notice Copyright 2012 Korenix Technology Co., Ltd. All rights reserved. Reproduction without permission is prohibited. Information provided in this manual is intended to be accurate and reliable. However, the original manufacturer assumes no responsibility for its use, or for any infringements upon the rights of third parties that may result from its use. The material in this document is for product information only and is subject to change without notice. While reasonable efforts have been made in the preparation of this document to assure its accuracy, Korenix assumes no liabilities resulting from errors or omissions in this document, or from the use of the information contained herein. Korenix reserves the right to make changes in the product design without notice to its users. Acknowledgments Korenix is a registered trademark of Korenix Technology Co., Ltd. All other trademarks or registered marks in the manual belong to their respective manufacturers. Korenix Overview 2
Table of Content Copyright Notice... 2 Acknowledgments... 2 Table of Content... 3 Overview... 4 Setup trial environment... 5 Install SDK... 6 Use the sample program... 10 Korenix Overview 3
Overview JetOS93 MySQL SDK include MySQL header files, precompiled libraries, and sample codes. In the next section, we will guide you from creating a database, add a table with fields, and use our sample code to query, add, and remove entries in the table. It should fulfill all requirements to create your own application connect to MySQL Database from JetBox. Korenix Overview 4
Setup trial environment You may want to setup a trial environment like the diagram below. In this section, you will need to install and setup a MySQL server. diagram 1: Trial environment First, install MySQL database on JetBox8000 series. The official Tutorial can be found in the following link: http://dev.mysql.com/doc/refman/5.5/en/ Second, connect to the MySQL database installed on JetBox8000 series: # mysql u root p Third, create a database named jetboxdemo : mysql> create database jetboxdemo; Forth, create a table called demo, with 5 data fields: mysql> use jetboxdemo; mysql> create table demo (idx int(50) not null auto_increment primary key,voltage DECIMAL(5,2),current DECIMAL(5,2),time TIMESTAMP, status varchar(10)); Finally, add some values into the demo table. mysql> INSERT INTO demo (voltage,current,time,status) VALUES(1.1,2.2,NOW(),"ok"); mysql> select * from demo; Korenix Setup trial environment 5
Install SDK The MySQL SDK, same as JetOS93 SDK, must be installed on your host computer running Linux (i.e. Fedora 9). Download and use the command tar to uncompress the SDK archive at your home directory. Notice: JetOS93 SDK V0.6 must be installed before you install JetOS93 MySQL SDK. For example: # cd ~ # tar zfx jetos93 mysql sdk v0.1.tar.gz Snapshot 2: The directory of the JetOS93 MySQL SDK Filename end with extension.cpp is comiple and link with arm linux g++: filename common.h Description define database ip, username, password Korenix Install SDK 6
filename delete.c delete.cpp insert.c insert.cpp select.c select.cpp showversion.c Description delete a entry from a table delete a entry from a table (c++) insert a entry to a table insert a entry to a table (c++) list entries in a table list entries in a table (c++) show MySQL version in the library In the include directory, files end with.h are mysql header files you might need to compile source code. Snapshot 2: The include directory of the JetOS93 MySQL SDK In the library directory, files end with.a are mysql static linked library. File end with.so is the share library. Korenix Install SDK 7
Snapshot 3: The library directory of the JetOS93 MySQL SDK Compile the source code is pretty simple, just type make and press <Enter>, then executable file should be generated. Then you can copy them to USB and mount it to JetBox. Note: You MUST modify the common.h according to your SQL settings: Snapshot 4: The common.h file Korenix Install SDK 8
Snapshot 5: The output of the JetOS93 MySQL SDK Snapshot 6: The Makefile of the JetOS93 MySQL SDK Korenix Install SDK 9
Use the sample program Assume you have created 4 entries in the demo table on the MySQL server side: You can list the entries with select (or select++) command on JetBox3300: To add an entry to the demo table, you can use insert (or insert ++) command, Usage: insert <voltage> <current> <status> There should be a new entry in the SQL server. To delete an entry from the demo table, you can use delete (or delte++) command, Usage: delete <row number> Then the entry with idx 6 should be remove from server. Korenix Use the sample program 10
Korenix Use the sample program 11