In theory you should not need to specify the provider when there is only one on the classpath when running in SE. (If this is not working for you right now then you should download the latest version of TopLink Essentials from the Glassfish.) It never hurts to put it in, though. You would simply include:
I have configured the persistence.xml as you have said, i was able to deploy the application successfully, but when I am running my client the continer was not able to find the table in the Database, eventhough i have created the Table in the right schema and provided the right credentials to connect to that schema in the persistence.xml. Does the container look for the DB credentials anywhere else.
As you have said I included the <property> tag in the persistence.xml, I got rid of that exception but I was not able to find any data in the tables. In the client code I do a create and then try to find the data that I created, it throws an EJBException as it was not able to find the data.
Moreover when I remove the finder and have the create code alone, it says that the record was created, I confirm this as manager.contains() returned true. But when I queried in the DB directly I was not able to find the data. So, I believe that the record is created in some other instance. The credentials that I have given in the persistence.xml to connect to the DB are correct, I have verified them again and again. I have also created a Datasource in the Application Server which is the same as the one given in the persistence.xml. I am not sure what I am missing here, where else would the data be created, were else would it find the credentials to connect to DB.
You also need to start and commit a transaction in order for the data to actually be persisted. I recommend that you take a look at the book sample code on the Apress site. It will likely help you to get started.
Are you sure your DataSource isn't used to make this connection, or possibly there is still a default datasource that is being used?
Bye, good luck
posted 14 years ago
I just looked into the samples of the book, so I changed my code to begin and commit transactions. Everything is working fine now, I have no exceptions, in the console I am able to see the correct outputs in my console, but the point is that I don't know where all these data are been written to. I did change my DB connection Info to wrong values in both persistence.xml and in the in the Application Server, but still everything is going fine I did not get any errors. I am using Sun Java Application Server is there anything like default DB connection available in this server.
There is a default server in SJAS 9.0 called JavaDB, i believe all the data that i create goes into that DB, I am not sure about this though. While creating the EntityManager I was creating it using the @PerssitenceContext annotation, is it because of that the value are getting written in JavaDB.
I changed the code to get the EntityManager from EntityManagerFactory. The code goes like this,