douzi9744 2016-11-09 03:12
浏览 72

如何重置从Go数据库/ SQL池获取的连接状态?

If I exec a db.exec("set time_zone = "+00:00""), the status time_zone of connection to exec the SQL will change and will the connection be put back to the pool?

If so, will it be reused by another processor who doesn't know the status of connection has been changed?

  • 写回答

1条回答 默认 最新

  • dongmei8071 2016-11-09 05:19
    关注

    The correct way is to set a timezone in the connection string:

    sql.Open("mysql", "root@tcp(127.0.0.1:3306)/dbname?charset=utf8&parseTime=true&time_zone=%2B00%3A00")
    

    Note that time_zone value must be urlencoded. Also you can set other system variables in conn string.

    评论

报告相同问题?

悬赏问题

  • ¥15 我想在一个软件里添加一个优惠弹窗,应该怎么写代码
  • ¥15 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流