[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Q : getting started using EclipseLink ?

Great, good to hear. You may want to file a bug about the password thing.

./tch



On Sun, Sep 7, 2008 at 9:27 PM, Penyihir Kecil <penyihirkecil@xxxxxxxxx> wrote:
> hey it's now works
> i think eclipselink doens't work if i provide an empty password in
> persistence.xml
> when i change the user in my mysql and make it with password
> then change the persistence.xml
>
> <property name="eclipselink.jdbc.user" value="root" />
> <property name="eclipselink.jdbc.password" value="admin" />
>
> it work smoothly....
>
>
> Penyihir Kecil <penyihirkecil@xxxxxxxxx> wrote:
>
> this is my trial of using eclipselink
>
> thnx u...^_^v
>
> Tim Hollosy <hollosyt@xxxxxxxxx> wrote:
>
> Could you post your configuration of your EntityManagerFactory?
>
> ./tch
>
>
>
> On Sun, Sep 7, 2008 at 8:27 PM, Penyihir Kecil wrote:
>> i tried this :
>>
>> Main.java
>> ...
>>
>> public class Main {
>> public static void main(String[] args){
>> EntityManagerFactory emf =
>>
>> Persistence.createEntityManagerFactory("HelloJPA");
>> EntityManager em = emf.createEntityManager();
>> UserService service = new UserService(em);
>>
>> em.getTransaction().begin();
>> User emp = service.createEmployee("aaa", "123", "admin");
>> em.getTransaction().commit();
>> }
>> }
>>
>> =========================================================
>>
>> User.java
>>
>> ...
>>
>> @Entity
>> @Table(name="USER", schema="database")
>> public class User implements Serializable {
>>
>>
>> @Id
>> private String Username;
>> private String Password;
>> private String Status;
>> private static final long serialVersionUID = 1L;
>>
>> public User() {
>> super();
>> }
>> public String getUsername() {
>> return this.Username;
>> }
>>
>> public void setUsername(String Username) {
>> this.Username = Username;
>> }
>> public String getPassword() {
>> return this.Password;
>> }
>>
>> public void setPassword(String Password) {
>> this.Password = Password;
>> }
>> public String getStatus() {
>> return this.Status;
>> }
>>
>> public void setStatus(String Status) {
>> this.Status = Status;
>> }
>>
>> }
>> =================================================
>> UserService.java
>>
>> ....
>>
>> public class UserService {
>> protected EntityManager em;
>> public UserService(EntityManager em) {
>> this.em = em;
>> }
>>
>> public User createEmployee(String username, String password, String
>> status) {
>> User emp = new User();
>> emp.setUsername(username);
>> emp.setPassword(password);
>> emp.setStatus(status);
>> em.persist(emp);
>> return emp;
>> }
>>
>> public void removeUser(String username) {
>> User emp = findUser(username);
>> if (emp != null) {
>> em.remove(emp);
>> }
>> }
>>
>> public User findUser(String username) {
>> return em.find(User.class, username);
>> }
>>
>> public Collection findAllUsers() {
>> Query query = em.createQuery("SELECT e FROM User e");
>> return (Collection) query.getResultList();
>> }
>> }
>>
>> ==========================================================
>>
>> Persistance.xml
>>
>>
>>
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>> xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
>> http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd";>
>>
>> org.eclipse.persistence.jpa.PersistenceProvider
>>
>> edu.its.bean.User
>>
>>
>> value="org.gjt.mm.mysql.Driver"/>
>>
>> value="jdbc:mysql://localhost:3306/database" />
>>
>>
>>
>>
>> value="drop-and-create-tables" />
>>
>> value="database" />
>>
>>
>> value="false"/>
>>
>>
>>
>>
>> =================================================
>>
>> and i got an error :
>> Exception in thread "main" java.lang.NullPointerException
>> at java.util.Hashtable.put(Unknown Source)
>> at java.util.Properties.setProperty(Unknown Source)
>> at
>>
>> com.mysql.jdbc.NonRegisteringDriver.parseURL(NonRegisteringDriver.java:756)
>> at
>> com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:277)
>> at java.sql.DriverManager.getConnection(Unknown Source)
>> at java.sql.DriverManager.getConnection(Unknown Source)
>> at
>>
>> org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:97)
>> at
>>
>> org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:164)
>> at
>>
>> org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.connectInternal(DatasourceAccessor.java:324)
>> at
>>
>> org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.connectInternal(DatabaseAccessor.java:264)
>> at
>>
>> org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.connect(DatasourceAccessor.java:407)
>> at
>>
>> org.eclipse.persistence.sessions.server.ConnectionPool.buildConnection(ConnectionPool.java:130)
>> at
>>
>> org.eclipse.persistence.sessions.server.ConnectionPool.startUp(ConnectionPool.java:367)
>> at
>>
>> org.eclipse.persistence.sessions.server.ServerSession.connect(ServerSession.java:500)
>> at
>>
>> org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.login(DatabaseSessionImpl.java:606)
>> at
>>
>> org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:211)
>> at
>>
>> org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:246)
>> at
>>
>> org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:69)
>> at
>>
>> org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:118)
>> at
>>
>> org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:112)
>> at
>>
>> org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:100)
>>
>>
>> is there something wrong with my code ??
>>
>>
>> thnx u
>>
>>
>> dwi ardi irawan - 'penyihirkecil'
>> http://dwiardiirawan.blogspot.com
>>
>> ________________________________
>> Dapatkan alamat Email baru Anda!
>> Dapatkan nama yang selalu Anda inginkan sebelum diambil orang lain!
>> _______________________________________________
>> eclipselink-users mailing list
>> eclipselink-users@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>>
>>
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>
>
>
> dwi ardi irawan - 'penyihirkecil'
> http://dwiardiirawan.blogspot.com
> ________________________________
> Nama baru untuk Anda!
> Dapatkan nama yang selalu Anda inginkan di domain baru @ymail dan
> @rocketmail.
> Cepat sebelum diambil orang
> lain!_______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>
>
>
> dwi ardi irawan - 'penyihirkecil'
> http://dwiardiirawan.blogspot.com
>
> ________________________________
> Nama baru untuk Anda!
> Dapatkan nama yang selalu Anda inginkan di domain baru @ymail dan
> @rocketmail.
> Cepat sebelum diambil orang lain!
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>
>