Tuesday 15 May 2012

java - Execute "SET ROLE" statement in eclipselink JPA -


I am using EclipseLink JPA to connect to the vertica database and get results. EntityManager em = ... query q = em.createQuery ("SELECT x FROM TABLE X") before running the part below the code; List results = q.getResultList ();

I need to run the "set ROLES ALL" statement for the User ID first. How to play such statements in JPA.

Please guide me.

For Vertica, you can do two things:

  1. Set your default role for the user:

      user myuser default role myrole; Use the ConneSettings connection string attribute as described in Virchica Connection String (Docs):  

    A string in which the SQL statement that the JDBC driver automatically runs after the database is connected This is useful for setting up property locale, setting a schema search path, or making other configurations that require connections.

    Your connection string may look like this:

     jdbc: vertica: // myverticaserver / mydb? ConnSettings = SET + ROLE + myrole      

No comments:

Post a Comment