func (my *Conn) IsConnected() bool {
	return my.net_conn != nil
}
Check if connection is established
package native
import (
	"bufio"
	"fmt"
	"io"
	"net"
	"reflect"
	"strings"
	"time"
	"github.com/ziutek/mymysql/mysql"
)
type serverInfo struct {
	prot_ver byte
	serv_ver []byte
	thr_id   uint32
	scramble [20]byte
	caps     uint16
	lang     byte
}
type Conn struct {
	proto string  
	laddr string  
	raddr string  
	user   string  
	passwd string  
	dbname string  
	net_conn net.Conn  
	rd       *bufio.Reader
	wr       *bufio.Writer
	info serverInfo  
	seq  byte        
	unreaded_reply bool
	init_cmds []string          
	stmt_map  map[uint32]*Stmt  
	status mysql.ConnStatus
	max_pkt_size int
	timeout time.Duration
	dialer mysql.Dialer
	narrowTypeSet bool
	fullFieldInfo bool
	Debug bool
}
func New(proto, laddr, raddr, user, passwd string, db ...string) mysql.Conn {
	my := Conn{
		proto:         proto,
		laddr:         laddr,
		raddr:         raddr,
		user:          user,
		passwd:        passwd,
		stmt_map:      make(map[uint32]*Stmt),
		max_pkt_size:  16*1024*1024 - 1,
		timeout:       2 * time.Minute,
		fullFieldInfo: true,
	}
	if len(db) == 1 {
		my.dbname = db[0]
	} else if len(db) > 1 {
		panic("mymy.New: too many arguments")
	}
	return &my
}
func (my *Conn) Credentials() (user, passwd string) {
	return my.user, my.passwd
}
func (my *Conn) NarrowTypeSet(narrow bool) {
	my.narrowTypeSet = narrow
}
func (my *Conn) FullFieldInfo(full bool) {
	my.fullFieldInfo = full
}
func (my *Conn) Clone() mysql.Conn {
	var c *Conn
	if my.dbname == "" {
		c = New(my.proto, my.laddr, my.raddr, my.user, my.passwd).(*Conn)
	} else {
		c = New(my.proto, my.laddr, my.raddr, my.user, my.passwd, my.dbname).(*Conn)
	}
	c.max_pkt_size = my.max_pkt_size
	c.timeout = my.timeout
	c.Debug = my.Debug
	return c
}
func (my *Conn) SetMaxPktSize(new_size int) int {
	old_size := my.max_pkt_size
	if new_size > 0 {
		my.max_pkt_size = new_size
	}
	return old_size
}
func (my *Conn) SetTimeout(timeout time.Duration) {
	my.timeout = timeout
}
func (my *Conn) NetConn() net.Conn {
	return my.net_conn
}
type timeoutError struct{}
func (e *timeoutError) Error() string   { return "i/o timeout" }
func (e *timeoutError) Timeout() bool   { return true }
func (e *timeoutError) Temporary() bool { return true }
type stringAddr struct {
	net, addr string
}
func (a stringAddr) Network() string { return a.net }
func (a stringAddr) String() string  { return a.addr }
var DefaultDialer mysql.Dialer = func(proto, laddr, raddr string,
	timeout time.Duration) (net.Conn, error) {
	if proto == "" {
		proto = "unix"
		if strings.IndexRune(raddr, ':') != -1 {
			proto = "tcp"
		}
	}
	d := &net.Dialer{Timeout: timeout}
	if laddr != "" {
		var err error
		switch proto {
		case "tcp", "tcp4", "tcp6":
			d.LocalAddr, err = net.ResolveTCPAddr(proto, laddr)
		case "unix":
			d.LocalAddr, err = net.ResolveTCPAddr(proto, laddr)
		default:
			err = net.UnknownNetworkError(proto)
		}
		if err != nil {
			return nil, err
		}
	}
	return d.Dial(proto, raddr)
}
func (my *Conn) SetDialer(d mysql.Dialer) {
	my.dialer = d
}
func (my *Conn) connect() (err error) {
	defer catchError(&err)
	my.net_conn = nil
	if my.dialer != nil {
		my.net_conn, err = my.dialer(my.proto, my.laddr, my.raddr, my.timeout)
		if err != nil {
			my.net_conn = nil
			return
		}
	}
	if my.net_conn == nil {
		my.net_conn, err = DefaultDialer(my.proto, my.laddr, my.raddr, my.timeout)
		if err != nil {
			my.net_conn = nil
			return
		}
	}
	my.rd = bufio.NewReader(my.net_conn)
	my.wr = bufio.NewWriter(my.net_conn)
	my.init()
	my.auth()
	res := my.getResult(nil, nil)
	if res == nil {
		my.oldPasswd()
		res = my.getResult(nil, nil)
		if res == nil {
			return mysql.ErrAuthentication
		}
	}
	for _, cmd := range my.init_cmds {
		my.sendCmdStr(_COM_QUERY, cmd)
		res := my.getResponse()
		row := res.MakeRow()
		for res != nil {
			if !res.StatusOnly() {
				for {
					err = res.getRow(row)
					if err == io.EOF {
						break
					} else if err != nil {
						return
					}
				}
			}
			if res, err = res.nextResult(); err != nil {
				return
			}
		}
	}
	return
}
func (my *Conn) Connect() (err error) {
	if my.net_conn != nil {
		return mysql.ErrAlredyConn
	}
	return my.connect()
}