Monday, April 9, 2012

protobuf.GeneratedMessage is a restricted class

I'm developing db driven web using cloud sql but when I open the link
in browser I got this error..

HTTP ERROR 500
Problem accessing /sql_engine_web. Reason:


com.google.appengine.repackaged.com.google.protobuf.GeneratedMessage
is a restricted class. Please see the Google App Engine developer's
guide for more details.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
I'm following the guestbook guide for making connection to google
cloud sql.

Here is how I'm doing.
===================
CONNECTION MANAGER
===================

package engine.connector;

import java.sql.DriverManager;

import com.google.appengine.api.rdbms.AppEngineDriver;
import com.google.cloud.sql.jdbc.Connection;

public class Cloud_SQL_Connector {

private Connection googleCon = null;
private String URL = "jdbc:google:rdbms://uni-cloud:unicloud/";

@SuppressWarnings("unused")
private String instanceName = "uni_cloud_db";

/**
* @author nasir
* @param instanceName that's the name of your database
*/
public Cloud_SQL_Connector(String instanceName) {
this.instanceName = instanceName;
URL += instanceName;
}

/**
* @author nasir
* @return the googleCon type of google cloud sql
* @param nothing
*/
public Connection getConnection() {
try {
DriverManager.registerDriver(new AppEngineDriver());
this.googleCon = (Connection) DriverManager.getConnection(URL);
} catch (Exception e) {
e.printStackTrace();
}
finally{
if(googleCon != null){
try {
googleCon.close();
} catch (Exception e2) {
e2.printStackTrace();
}
}
}
return googleCon;
}
}
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
============
MAIN SERVLET
============
private Connection con = null;

public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
PrintWriter out = resp.getWriter();
out.println("text/html");
Cloud_SQL_Connector connectionManager = new
Cloud_SQL_Connector("uni_cloud_db");
con = connectionManager.getConnection();

String statement = "insert into user (username, type)values (?, ?)";
try {
PreparedStatement stmt = con.prepareStatement(statement);
stmt.setString(1, "042-bscs-08");
stmt.setString(2, "student");
stmt.execute();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
if(con != null){
try {
con.close();
} catch (SQLException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
}
}

}
___________________________________________________________________________________________________________
Please help me in getting it fixed

No comments:

Post a Comment