如何解决Sybase数据库乱码问题详解
搭建测试数据库服务器时,遇到了乱码问题,之前没有遇到是因为开发数据库服务器是早就安装好并设置好字符集的,因此些问题在部署测试环境时才出现,当时已经将数据库配置完毕,并且所有的初始化脚本都已经执行完毕,工程也已经成功部署在WebLogic上,打开IE
搭建测试数据库服务器时,遇到了乱码问题,之前没有遇到是因为开发数据库服务器是早就安装好并设置好字符集的,因此些问题在部署测试环境时才出现,当时已经将数据库配置完毕,并且所有的初始化脚本都已经执行完毕,,工程也已经成功部署在WebLogic上,打开IE,运行程序,却发现所有从数据库中读取出来的都是乱码,经过上网搜索的相关资料,需要设置字符集,但刚开始查找到的资料基本是都是支言片语,没有一个系统的讲解如何设置字符集,几乎将他们所有的方法都试过了,结果不但没有弄好,甚至连控制台和SQL平台都是乱码了,实在弄不明白了,就去问高人了,他给我发了一个专门讲解字符集的文档,讲的很全面,而且通过他的帮忙终于将解决了乱码问题。
下面我总结一下设置字符集的过程:
1、安装完Sybase后,如果要想设置字符集为CP936,就必须先安装该字符集,因为Sybase默认的字符集表中并没有该字符集,安装步骤如下:(这里 SYBASE的安装路径为c:sybase) 1.c:>;cd sybasecharsetscp936 2.c:sybasecharsetscp936>; charset -Usa -Psa_pass -Sserver_name binary.srt cp936通过上述命令就成功将CP936字符集安装表Sybase的系统字符集表中,但必须重启Sybase服务两次才能看到结果,可以通过查看 master数据库中的syscharsets表查看是否已经安装成功,我们可以看到已经安装成功了:1002,171,0,1,'cp936', 'CP936 (Simplified Chinese).',’…’
2、看到CP936的编号为171,我们需要在Sybase的属性中设置系统字符集为该ID,如下图所示:
如果设置完字符集成出现错误,是因为master数据库的表空间默认只分配几百K的空间,导入新的数据后已经没有足够的空间了,所以要对master数据库设置大一些的表空间,点击master数据库右键属性,选择表空间的tab页,对原有的表空间编辑重新分配大小,将master所有的表空间都分配了就可以解决该问题。
3、 设置好字符集后就可以执行初始化脚本了。这其中还有几个小插曲,由于第二步的表空间不足的错误根本没有一个文档中有说明,所以我和郭立英根本谁也不知道,都以为Sybase被我们搞崩溃了呢,没办法只能重新安装,但安装后还是有该问题,后来请高人来帮我们看才知道是表空间的问题,还有就是虽然设置好字符集后,打开IE看还是乱码,不知道为什么,后来重新执行一遍脚本后就没有了,是因为之前默认的字符集为Cp850,所以用该字符集下执行的脚本再到CP936的环境中读取一定会乱码,所以在 CP936的环境中再执行一遍脚本就没有问题了。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics





Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

Hibernate polymorphic mapping can map inherited classes to the database and provides the following mapping types: joined-subclass: Create a separate table for the subclass, including all columns of the parent class. table-per-class: Create a separate table for subclasses, containing only subclass-specific columns. union-subclass: similar to joined-subclass, but the parent class table unions all subclass columns.

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())

To handle database connection errors in PHP, you can use the following steps: Use mysqli_connect_errno() to obtain the error code. Use mysqli_connect_error() to get the error message. By capturing and logging these error messages, database connection issues can be easily identified and resolved, ensuring the smooth running of your application.

HTML cannot read the database directly, but it can be achieved through JavaScript and AJAX. The steps include establishing a database connection, sending a query, processing the response, and updating the page. This article provides a practical example of using JavaScript, AJAX and PHP to read data from a MySQL database, showing how to dynamically display query results in an HTML page. This example uses XMLHttpRequest to establish a database connection, send a query and process the response, thereby filling data into page elements and realizing the function of HTML reading the database.

Through the Go standard library database/sql package, you can connect to remote databases such as MySQL, PostgreSQL or SQLite: create a connection string containing database connection information. Use the sql.Open() function to open a database connection. Perform database operations such as SQL queries and insert operations. Use defer to close the database connection to release resources.

Using the database callback function in Golang can achieve: executing custom code after the specified database operation is completed. Add custom behavior through separate functions without writing additional code. Callback functions are available for insert, update, delete, and query operations. You must use the sql.Exec, sql.QueryRow, or sql.Query function to use the callback function.

Use the DataAccessObjects (DAO) library in C++ to connect and operate the database, including establishing database connections, executing SQL queries, inserting new records and updating existing records. The specific steps are: 1. Include necessary library statements; 2. Open the database file; 3. Create a Recordset object to execute SQL queries or manipulate data; 4. Traverse the results or update records according to specific needs.
