June 6th, 2008
by Jared Richardson
http://www.jaredrichardson.net
What will we cover?
Downloading Subversion
Installing Subversion
Adding a new repository
Start a subversion server
Adding users
Get a copy of the code
See your Changes
Put your changes back in the server
Get everyone else’s changes
Adding a new file
Downloading Subversion
You need to download the Windows installer first, but that’s not quite as easy as you might think. The Subversion download […]
Tags: Subversion
Posted in Software Enginnering | No Comments »
June 3rd, 2008
connect, accept, send, and recv often cause “Interrupted System call” error when you are writting socket programs
you can solve this problem using:
/* Start with fd just returned by socket(), blocking, SOCK_STREAM… */
while ( connect (fd, &name, namelen) == -1 && errno != EISCONN )
if ( errno != EINTR )
[…]
Posted in Linux | 3 Comments »
June 2nd, 2008
Posted by Vivek on Tuesday April 18, 06 @4:18 pm
You can recover MySQL database server password with following five easy steps.
Step # 1: Stop the MySQL server process.
Step # 2: Start the MySQL (mysqld) server/daemon process with the –skip-grant-tables option so that it will not prompt for password
Step # 3: Connect to mysql server as […]
Tags: MySQL
Posted in MySQL | No Comments »
June 2nd, 2008
Posted by Vivek on Tuesday November 28, 06 @7:14 pm
Usually you run mysqldump to create database copy:
$ mysqldump -u user -p db-name > db-name.out
Copy db-name.out file using sftp/ssh to remote MySQL server:
$ scp db-name.out user@remote.box.com:/backup
Restore database at remote server (login over ssh):
$ mysql -u user -p db-name < db-name.out
How do I copy a MySQL database […]
Tags: MySQL
Posted in MySQL | No Comments »
June 2nd, 2008
MySQL change root password
Posted by Vivek on Monday January 2, 2006 [Last updated: September 29, 2007]
Q. How do I change MySQL root password under Linux, FreeBSD, OpenBSD and UNIX like operating system over ssh / telnet session?
A. Setting up mysql password is one of the essential tasks. root user is MySQL admin account. Remember Linux […]
Tags: MySQL
Posted in MySQL | 1 Comment »
June 1st, 2008
连接查询
通过连接运算符可以实现多个表查询。连接是关系数据库模型的主要特点,也是它区别于其它类型数据库管理系统的一个标志。
在关系数据库管理系统中,表建立时各数据之间的关系不必确定,常把一个实体的所有信息存放在一个表中。当检索数据时,通过连接操作查询出存放在多个表中 的不同实体的信息。连接操作给用户带来很大的灵活性,他们可以在任何时候增加新的数据类型。为不同实体创建新的表,尔后通过连接进行查询。
连接可以在SELECT 语句的FROM子句或WHERE子句中建立,似是而非在FROM子句中指出连接时有助于将连接操作与WHERE子句中的搜索条件区分开来。所以,在Transact-SQL中推荐使用这种方法。
SQL-92标准所定义的FROM子句的连接语法格式为:
FROM join_table join_type join_table
[ON (join_condition)]
其中join_table指出参与连接操作的表名,连接可以对同一个表操作,也可以对多表操作,对同一个表操作的连接又称做自连接。
join_type 指出连接类型,可分为三种:内连接、外连接和交叉连接。内连接(INNER JOIN)使用比较运算符进行表间某(些)列数据的比较操作,并列出这些表中与连接条件相匹配的数据行。根据所使用的比较方式不同,内连接又分为等值连 接、自然连接和不等连接三种。
网管联盟bitsCN@com
外连接 分为左外连接(LEFT OUTER JOIN或LEFT JOIN)、右外连接(RIGHT OUTER JOIN或RIGHT JOIN)和全外连接(FULL OUTER JOIN或FULL JOIN)三种。与内连接不同的是,外连接不只列出与连接条件相匹配的行,而是列出左表(左外连接时)、右表(右外连接时)或两个表(全外连接时)中所有 符合搜索条件的数据行。
交叉连接(CROSS JOIN)没有WHERE 子句,它返回连接表中所有数据行的笛卡尔积,其结果集合中的数据行数等于第一个表中符合查询条件的数据行数乘以第二个表中符合查询条件的数据行数。
连接操作中的ON (join_condition) 子句指出连接条件,它由被连接表中的列和比较运算符、逻辑运算符等构成。
无论哪种连接都不能对text、ntext和image数据类型列进行直接连接,但可以对这三种列进行间接连接。例如:
SELECT p1.pub_id,p2.pub_id,p1.pr_info
FROM pub_info AS p1 INNER JOIN pub_info AS p2
ON DATALENGTH(p1.pr_info)=DATALENGTH(p2.pr_info)
(一)内连接
内连接查询操作列出与连接条件匹配的数据行,它使用比较运算符比较被连接列的列值。内连接分三种:
1、等值连接:在连接条件中使用等于号(=)运算符比较被连接列的列值,其查询结果中列出被连接表中的所有列,包括其中的重复列。 中国网管论坛bbs.bitsCN.com
2、不等连接: 在连接条件使用除等于运算符以外的其它比较运算符比较被连接的列的列值。这些运算符包括>、>=、<=、<、!>、!<和<>。
3、自然连接:在连接条件中使用等于(=)运算符比较被连接列的列值,但它使用选择列表指出查询结果集合中所包括的列,并删除连接表中的重复列。
例,下面使用等值连接列出authors和publishers表中位于同一城市的作者和出版社:
SELECT *
FROM authors AS a INNER JOIN publishers AS p
ON a.city=p.city
又如使用自然连接,在选择列表中删除authors 和publishers 表中重复列(city和state):
SELECT a.*,p.pub_id,p.pub_name,p.country
FROM authors AS a INNER […]
Posted in Database | No Comments »
May 30th, 2008
A. define the interface
int ns_add( int x, int y, int* sum);
note that the return value is the used to determining the status of SOAP request, parameter x and y are two integer to be added. pay special attention to the last parameter “sum” which is a “pointer” to sum calculated.
B. Generate stub and skeleton
Run the stub/skeleton compiler
soapcpp2 -c add.h
the option “-c” tells stub/skeleton compiler to generate the C code instead of Cpp code. Now you will find files generate by the compiler in current directory. Pay attention to the file soapStub.h with function “soap_call_ns_add” declared in it . Your client code will invoke this function to fulfill a web service.
C. Build the client
with gSOAP, building a SOAP client can be summarized as :
- Invoke remote web service method generated by stub/skeleton compiler
// code for client: client.c
#include “soapH.h”
int main()
{
struct soap s;
int sum=0;
int a=3;
int b=4;
soap_init(&s);
if(soap_call_ns_add(&s,”localhost:50000″,NULL,a,b,∑)==SOAP_OK)
{
printf(”%d+%d=%d\n”,a,b,sum);
}
else
{
soap_print_fault(&s,stderr);
}
soap_end(&s);
soap_done(&s);
return 0;
}
remember to add the following lines of code into your client program, namespace is a mapping table used by codes generated by stub compiler.
struct Namespace namespaces[] =
{
{ “SOAP-ENV”, “http://schemas.xmlsoap.org/soap/envelope/” },
{ “SOAP-ENC”,”http://schemas.xmlsoap.org/soap/encoding/”},
{ “xsi”, “http://www.w3.org/1999/XMLSchema-instance” },
{ “xsd”, “http://www.w3.org/1999/XMLSchema” },
{ “ns”, “urn:Calc”},
{ NULL, NULL }
};
compile the client source files (remeber to copy stdsoap2.h and stdsoap2.c into current directory):
gcc -o client client.c soapC.c soapClient.c stdsoap2.c
D. Build the server
Build a SOAP using code the generated by gSOAP can be summarized as:
- Bind and listen for a client connection
- Process request ( using soap_serve)
code for server: server.c
#include “soapH.h”
int main()
{
struct soap soap;
int m, s; // master and slave sockets
soap_init(&soap);
m = soap_bind(&soap, “localhost”, 50000, 100);
if (m < 0)
soap_print_fault(&soap, stderr);
else
{
fprintf(stderr, “Socket connection successful: master socket = %d\n”, m);
while(1)
{
s = soap_accept(&soap);
if (s < 0)
{
soap_print_fault(&soap, stderr);
break;
}
if (soap_serve(&soap) != SOAP_OK) // process RPC request
soap_print_fault(&soap, stderr); // print error
fprintf(stdout, “request served\n”);
soap_end(&soap); // clean up everything and close socket
}
}
soap_done(&soap); // close master socket and detach environment
}
int ns_add(struct soap* soap, int x, int y,int * sum)
{
*sum=x+y;
return SOAP_OK;
}
struct Namespace namespaces[] =
{
{ “SOAP-ENV”, “http://schemas.xmlsoap.org/soap/envelope/” },
{ “SOAP-ENC”,”http://schemas.xmlsoap.org/soap/encoding/”},
{ “xsi”, “http://www.w3.org/1999/XMLSchema-instance” },
{ “xsd”, “http://www.w3.org/1999/XMLSchema” },
{ “ns”, “urn:Calc”},
{ NULL, NULL }
};
compile the server source files:
gcc -o server server.c soapC.c soapServer.c stdsoap2.c
E. Test
run the server
./server
run the client
./client
you will get the following line on the screen:
3+4=7
Yeah. That is all you need to build a simple service
For more information about gSOAP, please visit the author’s website
Introduction:
The gSOAP toolkit provides a SOAP/XML-to-C/C++ language binding to ease the development of SOAP/XML Web services and client application in C and C++.The gSOAP uses stub and skeleton compiler to map C or C++ types ( both build-in types and user-defined types) into XML data types. It’ s a open source toolkit and can be […]