2016-01-13 44 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,即。根本不涉及數據庫。