Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] DatasourceLogin


There might be several ways to override settings.
I do it with a sessionCustomizer.

in persistence.xml :
<property name="eclipselink.session.customizer" value="aurora.MySessionCustomizer"/>

then an ordinary java class:

public class MySessionCustomizer implements SessionCustomizer{
   public static volatile String jdbcpwd;
   public static volatile String dbfilename;
   public static volatile Integer dbinternalcacheKbyte = 32768;

   @Override
   public void customize(Session session) throws Exception {
       session.getLogin().setPassword(jdbcpwd);
       session.getLogin().setShouldTrimStrings(false);
session.getLogin().setQueryRetryAttemptCount(0); session.getLogin().setConnectionString("jdbc:h2:~/"+dbfilename+";CIPHER=AES;DB_CLOSE_DELAY=-1;CACHE_SIZE="+dbinternalcacheKbyte+";MODE=HSQLDB");

   }

}

Janda Martin skrev:
Hello,

  I have a problem. I'm trying to set JDBC connection property. I found that I need to set property with DatabaseLogin.setProperty(<key>, <value>).
Bud I don't know how to use this my DatabaseLogin object.

I use EclipseLink 1.0 under JavaSE

Current version
                    Map<String, Object> params = new HashMap<String, Object>();
                    params.put("eclipselink.jdbc.url", getServerJDBCURL());
                    params.put("eclipselink.jdbc.driver", getServerJDBCDriver());
                    params.put("eclipselink.jdbc.user", getServerJDBCUser());
                    params.put("eclipselink.jdbc.password", getServerJDBCPassword());

                    EntityManagerFactory factory = Persistence.createEntityManagerFactory("pu-test, params);
                    EntityManager entityManager = factory.createEntityManager();


Java SE replacement with:

                    DatabaseLogin databaseLogin = new DatabaseLogin();
//... set connection

                    databaseLogin.setProperty("key", "value");


What I need and I don't know how:
*) use settings from persistence unit from persistence.xml
*) replace jdbc connection with my values
*) set JDBC connection custom property  (eg.  "encoding" = "UTF-8")
*) get EntityManagerFactory and EntityManager.

  Thank you very much for your help.

 Martin
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users




Back to the top