Topic
  • 11 replies
  • Latest Post - ‏2013-11-22T14:54:01Z by snape
snape
snape
7 Posts

Pinned topic Getting Started with the WAS Liberty Profile

‏2013-11-20T10:34:25Z |

Hi everyone

I accurately followed this tutorial (DB2 version)

https://www.ibmdw.net/wasdev/docs/getting_started_with_the_was_liberty_profile/

but when I try to run the web application and submit the data a javax.trasaction.RollbackExceptions occurs.

During setup steps everything seems to work as reported in the tutorial, the only difference is in module 2.2 page 15: "The datasource DB2Connection is available as jdbc/DB2Connection" and "The jdbcDriver myJDBCDriver is available" messages don't appear in the console.

What should I do?

Can anyone help me? Thanks

  • Tom_McManus
    Tom_McManus
    8 Posts

    Re: Getting Started with the WAS Liberty Profile

    ‏2013-11-20T16:15:49Z  

    Look in the messages.log for hints as to why the database is throwing errors.  Also please include the server.xml to see how the JDBC is set up.

  • snape
    snape
    7 Posts

    Re: Getting Started with the WAS Liberty Profile

    ‏2013-11-20T18:50:24Z  

    Look in the messages.log for hints as to why the database is throwing errors.  Also please include the server.xml to see how the JDBC is set up.

    I attach the server.xml and messages.long files.

    Thank you for any answer.

    Attachments

  • Tom_McManus
    Tom_McManus
    8 Posts

    Re: Getting Started with the WAS Liberty Profile

    ‏2013-11-20T20:04:58Z  
    • snape
    • ‏2013-11-20T18:50:24Z

    I attach the server.xml and messages.long files.

    Thank you for any answer.

    Verify the DB2ADMIN,ACCOUNTS is accurate in the database,

     

    org.apache.openjpa.persistence.PersistenceException: "DB2ADMIN.ACCOUNTS" is an undefined name.. SQLCODE=-204, SQLSTATE=42704, DRIVER=4.7.85 {prepstmnt 2019825428 INSERT INTO ACCOUNTS (C_NUM, C_MONEY, C_NAME) VALUES (?, ?, ?)} [code=-204, state=42704]SQLCA OUTPUT[Errp=SQLNQ1FC, Errd=-2145779603, 0, 0, 0, -10, 0]
    "DB2ADMIN.ACCOUNTS" is an undefined name.. SQLCODE=-204, SQLSTATE=42704, DRIVER=4.7.85

     

    I am downloading DB2 to see what I am getting, but I remember doing these before and  them working.

    Thanks

    Tom

     
  • snape
    snape
    7 Posts

    Re: Getting Started with the WAS Liberty Profile

    ‏2013-11-20T21:25:33Z  

    Verify the DB2ADMIN,ACCOUNTS is accurate in the database,

     

    org.apache.openjpa.persistence.PersistenceException: "DB2ADMIN.ACCOUNTS" is an undefined name.. SQLCODE=-204, SQLSTATE=42704, DRIVER=4.7.85 {prepstmnt 2019825428 INSERT INTO ACCOUNTS (C_NUM, C_MONEY, C_NAME) VALUES (?, ?, ?)} [code=-204, state=42704]SQLCA OUTPUT[Errp=SQLNQ1FC, Errd=-2145779603, 0, 0, 0, -10, 0]
    "DB2ADMIN.ACCOUNTS" is an undefined name.. SQLCODE=-204, SQLSTATE=42704, DRIVER=4.7.85

     

    I am downloading DB2 to see what I am getting, but I remember doing these before and  them working.

    Thanks

    Tom

     

    You mean I have to check if I have the table accounts in my database, or what else?

    In that case, yes, I have, I checked the name of the table.

  • Tom_McManus
    Tom_McManus
    8 Posts

    Re: Getting Started with the WAS Liberty Profile

    ‏2013-11-21T21:54:39Z  
    • snape
    • ‏2013-11-20T21:25:33Z

    You mean I have to check if I have the table accounts in my database, or what else?

    In that case, yes, I have, I checked the name of the table.

    I get the same error when my port is 50000 yet my DB is configured for 50001.  I am still looking through this, but this may be one issue.

     

    Thanks,
    Tom

  • snape
    snape
    7 Posts

    Re: Getting Started with the WAS Liberty Profile

    ‏2013-11-21T22:28:14Z  

    I get the same error when my port is 50000 yet my DB is configured for 50001.  I am still looking through this, but this may be one issue.

     

    Thanks,
    Tom

    I'm pretty sure my port is 50000, in Eclipse I set this port to connect the db and I can see it in data source explorer, the connection succeed.

  • SolomanBarghouthi
    SolomanBarghouthi
    8 Posts

    Re: Getting Started with the WAS Liberty Profile

    ‏2013-11-22T00:09:43Z  
    • snape
    • ‏2013-11-20T21:25:33Z

    You mean I have to check if I have the table accounts in my database, or what else?

    In that case, yes, I have, I checked the name of the table.

    hi,  

    when you said you checked the table existence.  Did you sure its own by a user db2admin?  I noticed that the steps asks you to create a table but when connecting to the DB we don't connect with user db2admin.  This mean, that unless you are logged on with db2admin user, the table will be created under a schema named <your login id>. 

    to check do this:

    1- open a db2 command window
    2- connect to the database. so issue the following command
      > db2 CONNECT TO CUSTDB
    3- check if the table exists.  you can do that by issuing the following command:
      >db2 list tables | grep -i accounts

    on my system, the output looks like this:

    C:\Program Files (x86)\IBM\SQLLIB\BIN>db2 list tables | grep -i accounts
    ACCOUNTS                        BARGHOUT        T     2013-11-21-18.56.09.749000

    as you see, barghout is my userid and hence table created under it.  If you don't see that displayed as db2admin, then that would be your problem.

    how to fix it:

    - when you create the table, make sure to put db2admin in front the name.  Thus, like this:

    > db2 CREATE TABLE db2admin.ACCOUNTS (C_NUM SMALLINT NOT NULL, C_NAME CHARACTER(30)NOT NULL, C_MONEY BIGINT NOT NULL, PRIMARY KEY(C_NUM))

    to verify that its created, do this:

    a- connect to database using the db2admin user.  Like this:

    > db2 CONNECT TO CUSTDB user db2admin using <your passowrd goes here>
    b- check if the table exists.  you can do that by issuing the following command:
      >db2 list tables | grep -i accounts
    you should see this:

    C:\Program Files (x86)\IBM\SQLLIB\BIN>db2 list tables | grep -i accounts
    ACCOUNTS                        DB2ADMIN        T     2013-11-21-18.58.46.077001

     

    good luck !!

    Soloman 

  • snape
    snape
    7 Posts

    Re: Getting Started with the WAS Liberty Profile

    ‏2013-11-22T12:32:37Z  

    hi,  

    when you said you checked the table existence.  Did you sure its own by a user db2admin?  I noticed that the steps asks you to create a table but when connecting to the DB we don't connect with user db2admin.  This mean, that unless you are logged on with db2admin user, the table will be created under a schema named <your login id>. 

    to check do this:

    1- open a db2 command window
    2- connect to the database. so issue the following command
      > db2 CONNECT TO CUSTDB
    3- check if the table exists.  you can do that by issuing the following command:
      >db2 list tables | grep -i accounts

    on my system, the output looks like this:

    C:\Program Files (x86)\IBM\SQLLIB\BIN>db2 list tables | grep -i accounts
    ACCOUNTS                        BARGHOUT        T     2013-11-21-18.56.09.749000

    as you see, barghout is my userid and hence table created under it.  If you don't see that displayed as db2admin, then that would be your problem.

    how to fix it:

    - when you create the table, make sure to put db2admin in front the name.  Thus, like this:

    > db2 CREATE TABLE db2admin.ACCOUNTS (C_NUM SMALLINT NOT NULL, C_NAME CHARACTER(30)NOT NULL, C_MONEY BIGINT NOT NULL, PRIMARY KEY(C_NUM))

    to verify that its created, do this:

    a- connect to database using the db2admin user.  Like this:

    > db2 CONNECT TO CUSTDB user db2admin using <your passowrd goes here>
    b- check if the table exists.  you can do that by issuing the following command:
      >db2 list tables | grep -i accounts
    you should see this:

    C:\Program Files (x86)\IBM\SQLLIB\BIN>db2 list tables | grep -i accounts
    ACCOUNTS                        DB2ADMIN        T     2013-11-21-18.58.46.077001

     

    good luck !!

    Soloman 

    I think you're right, Solomon. The problem must be this.

    But the trick of renaming the table like db2admin.**** doesn't work for me. When I run list tables the name of the table is db2admin.**** and the owner of the table is still my user id. How can I get over this?

    Is there a way to create a table under the Control Center as db2admin?

  • SolomanBarghouthi
    SolomanBarghouthi
    8 Posts

    Re: Getting Started with the WAS Liberty Profile

    ‏2013-11-22T12:56:27Z  
    • snape
    • ‏2013-11-22T12:32:37Z

    I think you're right, Solomon. The problem must be this.

    But the trick of renaming the table like db2admin.**** doesn't work for me. When I run list tables the name of the table is db2admin.**** and the owner of the table is still my user id. How can I get over this?

    Is there a way to create a table under the Control Center as db2admin?

    Hi,

    No need to rename. Just create it explicitly under db2admin by specifying db2admin in the create table command.
     
     
    > db2 CONNECT TO CUSTDB 

    > db2 CREATE TABLE db2admin.ACCOUNTS (C_NUM SMALLINT NOT NULL, C_NAME CHARACTER(30)NOT NULL, C_MONEY BIGINT NOT NULL, PRIMARY KEY(C_NUM))

     
  • snape
    snape
    7 Posts

    Re: Getting Started with the WAS Liberty Profile

    ‏2013-11-22T14:42:28Z  

    Hi,

    No need to rename. Just create it explicitly under db2admin by specifying db2admin in the create table command.
     
     
    > db2 CONNECT TO CUSTDB 

    > db2 CREATE TABLE db2admin.ACCOUNTS (C_NUM SMALLINT NOT NULL, C_NAME CHARACTER(30)NOT NULL, C_MONEY BIGINT NOT NULL, PRIMARY KEY(C_NUM))

     

    Ok, that error is now fixed. But now this error occurs when i try to insert a record into the db:

    Internal Exception: com.ibm.db2.jcc.am.mo: "DB2ADMIN" does not have the required authorization or privilege to perform operation "INSERT"
    

    why?

    by the way, is it possible to change the settings so that the web application search for tables owned by my user id instead that db2admin?

  • snape
    snape
    7 Posts

    Re: Getting Started with the WAS Liberty Profile

    ‏2013-11-22T14:54:01Z  
    • snape
    • ‏2013-11-22T14:42:28Z

    Ok, that error is now fixed. But now this error occurs when i try to insert a record into the db:

    <pre dir="ltr">Internal Exception: com.ibm.db2.jcc.am.mo: "DB2ADMIN" does not have the required authorization or privilege to perform operation "INSERT" </pre>

    why?

    by the way, is it possible to change the settings so that the web application search for tables owned by my user id instead that db2admin?

    Ok, fixed!

    Instead of creating a new table owned by db2admin, I changed my database connection settings: in the username field, i replaced db2admin with my username, then modified persistence.xml in the same way and everything now works.

    Thank you very much for your help!