Topic
3 replies Latest Post - ‏2011-12-16T14:18:55Z by SystemAdmin
SystemAdmin
SystemAdmin
9224 Posts
ACCEPTED ANSWER

Pinned topic error font when use MySQL databse

‏2011-12-12T16:53:02Z |
In my resource handler
//
def onList()
{
def mgr = zero.data.Manager.create('currency')
def result = mgr.queryList('SELECT * FROM article')
logger.INFO{"Query Links Results size: " + result.size() }
request.headers.out."Content-Type" = "application/json-comment-filtered"
request.view="JSON"
request.json.output = result
render()
}

def onCreate() {
def art = zero.json.Json.decode(request.input[])
def updated = new java.sql.Timestamp(System.currentTimeMillis())
def data = zero.data.groovy.Manager.create('currency')

data.update("""
INSERT INTO smcurrency.article (title,content,updated) VALUES ($art.title, $art.content,$updated)
""")
request.headers.out."Content-Type" = "text/html; charset=utf8"
request.status = HttpURLConnection.HTTP_CREATED;
request.view = 'JSON'
request.json.output = art
render()
}
//
I post a JSON object as : {"title":"một","content":"nguyễn anh bằng xin chào các bạn"}
When I do a GET, the result is :
Anyone can show me the way fix this error ? Thank you.
Updated on 2011-12-16T14:18:55Z at 2011-12-16T14:18:55Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    9224 Posts
    ACCEPTED ANSWER

    Re: error font when use MySQL databse

    ‏2011-12-12T16:54:42Z  in response to SystemAdmin
    Sorry, the result of GET method is : " "
    • SystemAdmin
      SystemAdmin
      9224 Posts
      ACCEPTED ANSWER

      Re: error font when use MySQL databse

      ‏2011-12-14T19:37:47Z  in response to SystemAdmin
      Can you use mysql directly to verify that your post is correctly inserting into the database?
      • SystemAdmin
        SystemAdmin
        9224 Posts
        ACCEPTED ANSWER

        Re: error font when use MySQL databse

        ‏2011-12-16T14:18:55Z  in response to SystemAdmin
        Also, can you manually insert those values into your mysql db with the mysql command line, and retrieve them with the onList handler?