远程Sybase数据库技术支持,联系手机:13811580958,QQ:289965371!

 

随着Sybase被完全整合到SAP下,Sybase原来的支持网站被SAP Support Portal取代。
只有购买了SAP服务的用户才能使用账号登录SAP Support Portal进行介质下载、补丁升级、报Incident等。
目前,原Sybase所有产品(包括:Adaptive Server Enterprise、Sybase IQ、Replication Server、PowerDesigner等)的官方手册仍然可以从http://infocenter.sybase.com/help/index.jsp进行浏览或下载。暂不清楚该网站http://infocenter.sybase.com/help/index.jsp何时会被完全迁移到SAP Support上!
Sybase官方手册英文版有html和pdf两种格式,而中文版手册只有pdf一种格式。为了国内Sybase用户更方便、快捷地搜索Sybase常见产品的官方手册内容,特将中文版Sybase官方手册转为html格式!
Sybase产品官方手册中文版的html格式所有内容的版权归SAP公司所有!本博客站长是Sybase数据库的铁杆粉丝!

如有Sybase数据库技术问题需要咨询,请联系我!

  QQ :289965371 点击这里给我发消息
  Email:

以下官方手册为ASE 15.7 ESD#2中文版:

  1. 新增功能公告 适用于 Windows、Linux 和 UNIX 的 Open Server 15.7 和 SDK 15.7
  2. 新增功能摘要
  3. 新增功能指南
  4. ASE 15.7 发行公告
  5. 配置指南(windows)
  6. 安装指南(windows)
  7. 参考手册:构件块
  8. 参考手册:命令
  9. 参考手册:过程
  10. 参考手册:表
  11. Transact-SQL® 用户指南
  12. 系统管理指南,卷 1
  13. 系统管理指南,卷 2
  14. 性能和调优系列:基础知识
  15. 性能和调优系列:锁定和并发控制
  16. 性能和调优系列:监控表
  17. 性能和调优系列:物理数据库调优
  18. 性能和调优系列:查询处理和抽象计划
  19. 性能和调优系列:使用 sp_sysmon 监控 Adaptive Server
  20. 性能和调优系列:利用统计分析改进性能
  21. 程序员参考 jConnect for JDBC 7.0.7
  22. Adaptive Server Enterprise 中的 Java
  23. 组件集成服务用户指南
  24. Ribo 用户指南
  25. 内存数据库用户指南
  26. Sybase Control Center for Adaptive Server® Enterprise
  27. 安全性管理指南
  28. 实用程序指南

 


< 上一个 | 内容 | 下一步 >

JDBCExamples

// An example class illustrating the use of JDBC facilities

// with the Java in Adaptive Server feature.

//

// The methods of this class perform a range of SQL operations.

// These methods can be invoked either from a Java client,

// using the main method, or from the SQL server, using

// the serverMain method.

//

import java.sql.*; // JDBC public class JDBCExamples {

{


main() 方法

// The main method, to be called from a client-side command line

//

public static void main(String args[]) { if (args.length!=2) {

System.out.println("\n Usage: "

+ "java ExternalConnect server-name:port-number action ");

System.out.println(" The action is connect, createtable, " + "createproc, drop, "

+ "insert, select, update, or call \n" ); return;

}

try{

String server = args[0];

String action = args[1].toLowerCase(); Connection con = connecter(server);

String workString = doAction( action, con, client); System.out.println("\n" + workString + "\n");

} catch (Exception e) { System.out.println("\n Exception: "); e.printStackTrace();

}

}


serverMain( ) 方法

// A JDBCExamples method equivalent to 'main',

// to be called from SQL or Java in the server


public static String serverMain(String action) { try {

Connection con = connecter("default");

String workString = doAction(action, con, server); return workString;

} catch ( Exception e ) {

if (e.getMessage().equals(null)) { return "Exc: " + e.toString();

} else {

return "Exc - " + e.getMessage();

}

}

}


connecter( ) 方法

// A JDBCExamples method to get a connection.

// It can be called from the server with argument 'default',

// or from a client, with an argument that is the server name.


public static Connection connecter(String server)

throws Exception, SQLException, ClassNotFoundException {


String forName=""; String url="";


if (server=="default") { // server connection to current server forName = "sybase.asejdbc.ASEDriver";

url = "jdbc:default:connection";

} else if (server!="default") { //client connection to server forName= "com.sybase.jdbc.SybDriver";

url = "jdbc:sybase:Tds:"+ server;

}


String user = "sa"; String password = "";


// Load the driver Class.forName(forName);

// Get a connection


Connection con = DriverManager.getConnection(url, user, password);

return con;

}


doAction( ) 方法

// A JDBCExamples method to route to the 'action' to be performed


public static String doAction(String action, Connection con, String locale)

throws Exception {


String createProcScript =

" create proc inoutproc @id int, @newname varchar(50),

@newhome Address, "

+ " @oldname varchar(50) output, @oldhome Address output as "

+ " select @oldname = name, @oldhome = home from xmp where id=@id "

+ " update xmp set name=@newname, home = @newhome where id=@id ";

String createTableScript =

" create table xmp (id int, name varchar(50), home Address)" ;


String dropTableScript = "drop table xmp "; String dropProcScript = "drop proc inoutproc ";

String insertScript = "insert into xmp "

+ "values (1, 'Joe Smith', new Address('987 Shore', '12345'))";


String workString = "Action (" + action + ) ; if (action.equals("connect")) {

workString += "performed";

} else if (action.equals("createtable")) { workString += doSQL(con, createTableScript );

} else if (action.equals("createproc")) { if (locale.equals(server)) {

throw new exception (CreateProc cannot be performed in the server);

} else {

workString += doSQL(con, createProcScript );

}

} else if (action.equals("droptable")) {


workString += doSQL(con, dropTableScript );

} else if (action.equals("dropproc")) { if (locale.equals(server)) {

throw new exception (CreateProc cannot be performed in the server);

} else {

workString += doSQL(con, dropProcScript );

}

} else if (action.equals("insert")) { workString += doSQL(con, insertScript );

} else if (action.equals("update")) { workString += updater(con);

} else if (action.equals("select")) { workString += selecter(con);

} else if (action.equals("call")) { workString += caller(con);

} else { return "Invalid action: " + action ;

}

return workString;

}


doSQL( ) 方法

// A JDBCExamples method to execute an SQL statement.


public static String doSQL (Connection con, String action) throws Exception {


Statement stmt = con.createStatement(); int res = stmt.executeUpdate(action); return "performed";

}


updater( ) 方法

// A method that updates a certain row of the 'xmp' table.

// This method illustrates prepared statements and parameter markers.


public static String updater(Connection con) throws Exception {


String sql = "update xmp set name = ?, home = ? where id = ?"; int id=1;


Address home = new Address("123 Main", "98765"); String name = "Sam Brown";

PreparedStatement pstmt = con.prepareStatement(sql); pstmt.setString(1, name);

pstmt.setObject(2, home); pstmt.setInt(3, id);

int res = pstmt.executeUpdate(); return "performed";

}


selecter( ) 方法

// A JDBCExamples method to retrieve a certain row

// of the 'xmp' table.

// This method illustrates prepared statements, parameter markers,

// and result sets.


public static String selecter(Connection con) throws Exception {


String sql = "select name, home from xmp where id=?"; int id=1;

Address home = null; String name = ""; String street = ""; String zip = "";

PreparedStatement pstmt = con.prepareStatement(sql); pstmt.setInt(1, id);

ResultSet rs = pstmt.executeQuery(); if (rs.next()) {

name = rs.getString(1);

home = (Address)rs.getObject(2); if (rs.next()) {

throw new Exception("Error: Select returned multiple rows");

} else { // No action

}

} else { throw new Exception("Error: Select returned no rows");

}

return "- Row with id=1: name("+ name + )

+ " street(" + home.street + ) zip("+ home.zip + );


caller( ) 方法

// A JDBCExamples method to call a stored procedure,

// passing input and output parameters of datatype String

// and Address.

// This method illustrates callable statements, parameter markers,

// and result sets.


public static String caller(Connection con) throws Exception {

CallableStatement cs = con.prepareCall("{call inoutproc (?, ?, ?, ?, ?)}");

int id = 1;

String newName = "Frank Farr";

Address newHome = new Address("123 Farr Lane", "87654"); cs.setInt(1, id);

cs.setString(2, newName); cs.setObject(3, newHome);

cs.registerOutParameter(4, java.sql.Types.VARCHAR); cs.registerOutParameter(5, java.sql.Types.JAVA_OBJECT); int res = cs.executeUpdate();

String oldName = cs.getString(4);

Address oldHome = (Address)cs.getObject(5);

return "- Old values of row with id=1: name("+oldName+ ) street(" + oldHome.street + ") zip("+ oldHome.zip + );

}

}




--------------------------------------华丽的分割线-------------------------------------------------------------------------
之前就已经研发成功了能够从Sybase SQL Anywhere的DB文件中恢复数据的工具:ReadASADB。
此工具支持ASA v5.0,v6.0,v7.0,v8.0,v9.0,v10.0,v11.0,v12.0等版本。
恢复Sybase SQL Anywhere的工具在国内应该算首创。

ReadASADB功能
能够从损坏的SQL Anywhere数据文件(.db)和UltraLite数据文件(.udb)上提取数据的非常规恢复工具

  1. 适用于所有的SQL Anywhere版本    包括:5.x,6.x,7.x,8.x,9.x,10.x,11.x,12.x
  2. 适用于所有的UltraLite版本
  3. 能够恢复出来表结构和数据
  4. 能够恢复自定义数据类型
  5. 能够恢复存储过程等对象的语法
  6. 能够导出到目标数据库
  7. 能够导出到SQL文件并生成导入脚本
  8. 支持多种字符集  包括:cp850、cp936、gb18030、utf8等
  9. 能够恢复未加密或者简单加密类型的数据
  10. 简单易用
  11. 限制:不支持AES加密的数据文件
请参考:研发成功了从Sybase SQL Anywhere的DB文件上恢复数据的工具
            SQL Anywhere数据库非常规恢复工具ReadASADB使用介绍

ReadASADB适用场景

各种误操作:

  1. 误截断表(truncate table)
  2. 误删除表(drop table)
  3. 错误的where条件误删数据
  4. 误删除db或log文件
  5. 误删除表中的字段

本工具的应用场景:

1.因为物理磁盘故障、操作系统、系统软件方面或者掉电等等原因导致的Sybase SQL Anywhere数据库无法打开的情况;
2.误操作,包括truncate table,drop table,不正确的where条件导致的误删除等;
Sybase SQL Anywhere无法打开时,比较常见的错误是:Assertion failed。
如:
1、Internal database error *** ERROR *** Assertion failed:201819 (8.0.1.2600) Checkpoint log: invalid bitmap page -- transaction rolled back
2、Internal database error *** ERROR *** Assertion failed:201819 (8.0.1.2600) Page number on page does not match page requested -- transaction rolled back
3、Internal database error *** ERROR *** Assertion failed:200502 (9.0.2.2451) Checksum failure on page 23 -- transaction rolled back
4、File is shorter than expected
5、Internal database error *** ERROR *** Assertion failed: 201116 Invalid free list index page found while processing checkpoint log -- transaction rolled back
6、*** ERROR *** Assertion failed: 51901 Page for requested record not a table page or record not present on page等等。
+-------------------------------------华丽的分割线-------------------------------------------------------------------------