search
HomeDatabaseMysql TutorialSQL Anywhere 11 (Panorama) 评审指南 Part IX_Mssql系列教程

例程可通过下载
本文档中出现的SQL Anywhere 11在其它地方可能出现为SQL Anywhere Panorama。

JSON Web Service
JASON(JavaScript Object Notation)是一种简单、轻量级的数据交换格式,非常适用于展现和交换数据结构。虽然JSON独立于编程语言,但大多数情况下都使用JavaScript因为JSON对象能轻松重建和使用数据结构。SQL Anywhere 11通过内置的HTTP服务器支持web服务的请求来返回JSON格式的结果集。结果集通过键值对的数组来返回,每个键代表结果集中的一列。

JSON Web Service例程
本例程使用SQL Anywhere demo数据库用JSON格式返回employees列表并显示在浏览器中。其中使用了JSON列表,员工的名字也显示了出来。Employees的JSON列表通过一个返回到服务器的AJAX请求来获得。本例使用了SQL Anywhere的内置HTTP服务器,需要支持JavaScript的浏览器。

1. 确保没有数据库服务器运行。若有,请关闭。
2. 在命令行中,浏览至例程的JSON目录。
3. 执行以下命令将SQL Anywhere 11 demo数据库拷贝至当前目录:

copy "%SQLANYSAMP11%demo.db" .

4. 启动demo数据库的HTTP服务器。以下命令指定HTTP服务器的端口号为8080(如果需要,请指定其它端口):

dbsrv11 demo.db -xs "http(port=8080)"

5. 启动Interactive SQL并连接至demo数据库:

dbisql -c "eng=demo;uid=DBA;pwd=sql"

6. 创建一个从当前目录读取HTML页面的存储过程。拷贝以下代码至Interactive SQL中,按F5运行:

CREATE PROCEDURE sp_root()
BEGIN
CALL dbo.sa_set_http_header( ''Content-Type'', ''text/html'' );
SELECT xp_read_file( ''json.html'');
END;

7. 创建root web服务,返回HTML页面。拷贝以下代码至Interactive SQL中,按F5运行:

CREATE SERVICE "root"
TYPE ''RAW''
AUTHORIZATION OFF
USER DBA
AS CALL sp_root();

8. 创建employees web服务,由json.html调用。拷贝以下代码至Interactive SQL中,按F5运行:

CREATE SERVICE "employees"
TYPE ''JSON''
AUTHORIZATION OFF
USER DBA
AS SELECT * FROM "Employees";

9. 打开浏览器,浏览。
10. 点击“Get Employees”发起AJAX对emplyees web服务的请求demo数据库中的employees列表即显示。

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Adding Users to MySQL: The Complete TutorialAdding Users to MySQL: The Complete TutorialMay 12, 2025 am 12:14 AM

Mastering the method of adding MySQL users is crucial for database administrators and developers because it ensures the security and access control of the database. 1) Create a new user using the CREATEUSER command, 2) Assign permissions through the GRANT command, 3) Use FLUSHPRIVILEGES to ensure permissions take effect, 4) Regularly audit and clean user accounts to maintain performance and security.

Mastering MySQL String Data Types: VARCHAR vs. TEXT vs. CHARMastering MySQL String Data Types: VARCHAR vs. TEXT vs. CHARMay 12, 2025 am 12:12 AM

ChooseCHARforfixed-lengthdata,VARCHARforvariable-lengthdata,andTEXTforlargetextfields.1)CHARisefficientforconsistent-lengthdatalikecodes.2)VARCHARsuitsvariable-lengthdatalikenames,balancingflexibilityandperformance.3)TEXTisidealforlargetextslikeartic

MySQL: String Data Types and Indexing: Best PracticesMySQL: String Data Types and Indexing: Best PracticesMay 12, 2025 am 12:11 AM

Best practices for handling string data types and indexes in MySQL include: 1) Selecting the appropriate string type, such as CHAR for fixed length, VARCHAR for variable length, and TEXT for large text; 2) Be cautious in indexing, avoid over-indexing, and create indexes for common queries; 3) Use prefix indexes and full-text indexes to optimize long string searches; 4) Regularly monitor and optimize indexes to keep indexes small and efficient. Through these methods, we can balance read and write performance and improve database efficiency.

MySQL: How to Add a User RemotelyMySQL: How to Add a User RemotelyMay 12, 2025 am 12:10 AM

ToaddauserremotelytoMySQL,followthesesteps:1)ConnecttoMySQLasroot,2)Createanewuserwithremoteaccess,3)Grantnecessaryprivileges,and4)Flushprivileges.BecautiousofsecurityrisksbylimitingprivilegesandaccesstospecificIPs,ensuringstrongpasswords,andmonitori

The Ultimate Guide to MySQL String Data Types: Efficient Data StorageThe Ultimate Guide to MySQL String Data Types: Efficient Data StorageMay 12, 2025 am 12:05 AM

TostorestringsefficientlyinMySQL,choosetherightdatatypebasedonyourneeds:1)UseCHARforfixed-lengthstringslikecountrycodes.2)UseVARCHARforvariable-lengthstringslikenames.3)UseTEXTforlong-formtextcontent.4)UseBLOBforbinarydatalikeimages.Considerstorageov

MySQL BLOB vs. TEXT: Choosing the Right Data Type for Large ObjectsMySQL BLOB vs. TEXT: Choosing the Right Data Type for Large ObjectsMay 11, 2025 am 12:13 AM

When selecting MySQL's BLOB and TEXT data types, BLOB is suitable for storing binary data, and TEXT is suitable for storing text data. 1) BLOB is suitable for binary data such as pictures and audio, 2) TEXT is suitable for text data such as articles and comments. When choosing, data properties and performance optimization must be considered.

MySQL: Should I use root user for my product?MySQL: Should I use root user for my product?May 11, 2025 am 12:11 AM

No,youshouldnotusetherootuserinMySQLforyourproduct.Instead,createspecificuserswithlimitedprivilegestoenhancesecurityandperformance:1)Createanewuserwithastrongpassword,2)Grantonlynecessarypermissionstothisuser,3)Regularlyreviewandupdateuserpermissions

MySQL String Data Types Explained: Choosing the Right Type for Your DataMySQL String Data Types Explained: Choosing the Right Type for Your DataMay 11, 2025 am 12:10 AM

MySQLstringdatatypesshouldbechosenbasedondatacharacteristicsandusecases:1)UseCHARforfixed-lengthstringslikecountrycodes.2)UseVARCHARforvariable-lengthstringslikenames.3)UseBINARYorVARBINARYforbinarydatalikecryptographickeys.4)UseBLOBorTEXTforlargeuns

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools