2016-01-13 43 views
0

我正在尝试使用泽西岛和谷歌云平台构建RESTful api。使用谷歌云平台和泽西岛创建RESTful api

我已经部署了应用程序和下面这个环节我都可以访问它精细

http://2-dot- {应用程序ID} .appspot.com访问/ API /员工

但是每当我试图访问存储

SQL数据库在那里我有问题

我可以用续集亲精细访问数据库,但每当我试图编写一个解决方案来访问它,我得到的各种错误,其中包括:

org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor aroundWriteTo: MessageBodyWriter not found for media type=application/json, type=class java.util.ArrayList, genericType=java.util.ArrayList<com.staff.webservice.models.StaffInfo>. 

这是我的代码迄今访问数​​据库,因为我已删除了以前的代码出于无奈,现在不能得到它回来

import java.sql.DriverManager; 
import java.util.ArrayList; 

import java.io.*; 
import java.sql.*; 
import com.google.appengine.api.utils.SystemProperty; 

public class StaffDAO implements Staff{ 
public ArrayList<StaffInfo> getAllStaff() { 

    ArrayList<StaffInfo> staffArray = new ArrayList<>(); 

    Connection connection = null; 

    try { 
     // Load the JDBC driver 
     String driverName = "com.mysql.jdbc.Driver"; // MySQL MM JDBC driver 
     Class.forName(driverName); 

     // Create a connection to the database 

     String url = "jdbc:google:mysql://{application-id}:staff-database?user={username}"; 
     String username = "{username}"; 
     String password = "{password}"; 
     String databaseName = "staff-database"; 
     String driver = "com.mysql.jdbc.GoogleDriver"; 


     connection = DriverManager.getConnection(url, username, password); 

     System.out.println(connection.toString()); 




    } catch (ClassNotFoundException e) { 
     // Could not find the database driver 
    } catch (SQLException e) { 
     // Could not connect to the database 
    } 


    return staffArray; 
} 
} 

我怎样才能连接到数据库和查询它来检索数据和将数据发布到数据库。

回答

0

我看起来像错误是相关的方法的结果类型不是可序列化为JSON,即。根本不涉及数据库。