package xugu import ( "bytes" "database/sql/driver" "errors" "fmt" "net" "sync" ) type xuguConn struct { dsnConfig conn net.Conn mu sync.Mutex Type HANDLE_TYPE // 句柄类型 useSSL bool // 是否使用加密 havePrepare int //default 0 bkChar byte prepareNo int //fashengqi prepareName string //presPrepareCata *Result params *XGCSParam errStr []byte sendBuff bytes.Buffer readBuff buffer } type dsnConfig struct { IP string Port string Database string User string Password string Encryptor string //加密库的解密口令 CharSet string //客户端使用的字符集名 TimeZone string IsoLevel string //事务隔离级别 LockTimeout string //加锁超时 AutoCommit string StrictCommit string Result string ReturnSchema string ReturnCursorID string LobRet string ReturnRowid string Version string } func (xgConn *xuguConn) get_error() error { return nil } func (xgConn *xuguConn) Begin() (driver.Tx, error) { return nil, nil } func (xgConn *xuguConn) Prepare(query string) (driver.Stmt, error) { fmt.Println(">>>>>(xgConn *xuguConn) Prepare(query string)") //判断sql类型 switch switchSQLType(query) { case SQL_PROCEDURE: return nil, errors.New("Prepare does not support stored procedures") case SQL_UNKNOWN: return nil, errors.New("Unknown SQL statement type") case SQL_CREATE: return nil, errors.New("Prepare does not support DDL.") } stmt := &xuguStmt{ stmt_conn: xgConn, prepared: true, prename: make([]byte, 128), curopend: false, curname: make([]byte, 128), param_count: 0, result: nil, mysql: query, } return stmt, nil } func (xgConn *xuguConn) Close() error { fmt.Println("Close connection") err := xgConn.conn.Close() if err != nil { fmt.Println("Close connection error") return err } return nil }