SQL table not created when deploying a WAR file to Liferay - sql

I've created a JSR-268 portlet for Liferay which uses services to interact with a database. I can deploy the portlet without problems or errors, but the table defined by the services is not created!
I get no "table not found" error when I test the portlet. I get no errors at all! The table just isn't there in the database. I've found other things on the internet saying that I should use the generated "create.sql" file that the Liferay Service Builder created, but I don't see that file anywhere.
Can someone help me out?

Have the tables never been created? I had a similar problem when I deleted the tables by hand. I thought they would be created again when deploying the portlet again, but it didn't happen.
After studying the source code I found out that Liferay stores information about the portlets in the table servicecomponent and checks 2 things before it executes the (pseudo) SQL in META-INF/tables.sql:
The build.number in service.properties must be higher than that, stored in servicecomponent,
The tables.sql must be different from the one stored in servicecomponent.
Only then the tables.sql is executed.
An easy way to achieve that, is to delete all entries in servicecomponent addressing your portlet.

Try by deleting an entry from servicecomponent table. And redeploy your portlet.
delete FROM servicecomponent where buildNamespace="<your table namespace>"

I have faced the same problem and below given solution works for me.
Steps
I have changed the build.number in service.properties higher than that stored in servicecomponent.
Removed all the xml files from META-INF folder.
Removed all the sql files from webapp/WEB-INF/sql folder.
Then build-service and deploy will creates custom tables that are defiend in service.xml file.

If you're using serviceBuilder in Liferay 6.2 when you define a new entity in the Liferay schema in service.xml, the first time that any Portlet tries to access the table it will be created if it's not exist.
There are several problems when you're using a different schema because sometimes Liferay not create tables automatically. Then you need to lauch the Creation SQL sentence and create it manually and then access it through LocalServiceUtil.

Related

Prestashop 1.7: Can I use another database just for executing a side script?

I have created a Prestashop website with a database N°1. For some reasons, I want to write a script, that I'll execute a few times and that will simply fill a database N°2 with some data. This script has nothing to do with my Prestashop website, but is part of the same project and then, must be hosted in the same server, and moreover must be present within the Prestashop website's files (under a module directory I've made).
My question is: is it possible to use this database N°2 (only for this script)? Can I use Prestashop's Db.php class to do it?
Don't hesitate to ask for more informations if I'm not clear.
So if i am reading your post correctly you want to create two databases.
For example "prestashop_n1" and "prestashop_n2".
prestashop_n1 contains all prestashop required tables.
prestashop_n2 contains data extracted from prestashop_n1
In order to extracted data from prestashop_n1 to prestashop_n2 you could write a module.
In this module you can create a database connection to database prestashop_n2
You can use PHP to copy data from prestashop_n1 to prestashop_n2
Alternative you can add a cron-job to execute your script for copying data x times a day.

mondrian.xml schema files pentaho location

I'm creating cubes (xml schemas) via schema-workbench or ivy schema editor.
When I'm publishing it, I would like to know where the schemas (mondrian.xml files) are actually saved,What is the location of these files?
Thanks,
Which version of Pentaho BA server are you using? Pre or Post 5.0?
Pre 5.0: you choose the file path when publishing. The path is under you ${BISERVER}/pentaho-solutions.
5.0 and beyond: there's no physical file, it's stored in Pentaho's Jackrabbit repository only.
If you create any Analysis in Mondrian 5.*, and you have a test server and prod server, don't export Mondrian schemas from one to another. For a mystical reason you won't be able to get rid of them later.
This was my case, when I started searching for the pentaho-solutions/system/olap/datasources.xml in order to delete the problematic mondrian scheme. This source just doesn't exist anymore.
All data is now saved with the help of Jackrabbit. Jackrabbit stores your Mondrian Schemas together with all other Reports and Analysis to the database (the path is given in the jackrabbit preference file). But in the database you can only see their IDs. So there is no chance to get rid of one object - you leave everything or delete everything by truncating the table. The main problem is, that in the same table are saved not only schemas, but also all other reports, which you have downloaded to the server.

Add tables to the database on cloudbees or run .sql file for database in cloudbees

I have an AppFuse struts 2 app. I am trying to deploy it on cloudbees. I have created a database and bound it with the DB but I am not sure how to add tables to the database on cloudbees. Is there a way I can run .sql script on database created in cloudbees?
Also when I try to run the app using link it gives error Requested resource not available. I am guessing its because of lack of DB . Can anyone help me on adding tables and data to DB? and also execute the app smoothly on cloudbees?
Thanks a ton for your help.
You can add the tables and populate the data using different ways. You have here an article which explains you how to do it.
From your application, using Spring, you can use something like this. You need to figure it out for other frameworks.
<!-- Database initializer. If any of the script fails, the initialization stops. -->
<jdbc:initialize-database data-source="dataSource">
<jdbc:script location="${jdbc.initLocation}"/>
<jdbc:script location="${jdbc.dataLocation}"/>
</jdbc:initialize-database>
If you plan to use a MySQL client, then you should take a look at this, which explains it step by step.
Regarding how to deploy and to bind a Tomcat 7 app with your database, you can take a look at this blog post.
You can find info about all the containers we support here.

Netbeans - generating entity class from database

I am using netbeans IDE 7.1. I am trying to generate entity classes from a database(sql server). I am able to setup the connection to this remote datasource but in the New Entity Classes from database Wizard the tables are not showing up and at the bottom it says select atleast one table.
I could execute queries and browse through the tables from the netbeans databases service.
Can someone help me to fix this..
Thanks
maybe your schema is not selected correctly, check on service windows->database->your connection(the bold schema is a default selected schema) if it wrong, right-click->properties, and change your schema to public, all the tables that you created are here normally
hope useful :)
I faced this issue and the only way I could get it to work was to create a new connection every time. Once i created a new connection it would show me the tables and I could use it, otherwise it would just leave the list empty
In the newer versions of NetBeans if you create a database connection with default schema, it will take mysql as schema name and generate the connection string.
So goto your DB connection in NetBeans and edit your connection url.
Example :
Change
jdbc:mysql://localhost:3306/mysql?zeroDateTimeBehavior=CONVERT_TO_NULL
to
jdbc:mysql://localhost:3306/YOUR_SCHEMA_NAME?zeroDateTimeBehavior=CONVERT_TO_NULL (add your schema name in the connection string and save)
I had to go into Glassfish console and create a special connnection pool and resource. The connection pool had to be res-type="java.sql.Driver" (not datasource). Then when creating my entity, I picked this new resource from the list and it worked, my tables showed up.

Making a SETUP file

I have a VB project that runs on SQL SERVER 2005, while making the setup file for it, how do I include the DB?
You don't
Typically you have a DB generation script that is run either as part of setup or as part of first run of application
You also need to consider migrations (changes to DB when new releases of your application are published)
Consider using MigratorDotNet or RikMigrations to solve these problems in a seperate installer/upgrade program if you are still using VB6
I disagree, you could include the database. Simply distribute the .MDF file with your application.
Of course, the setup application would have know how to attach the database to an existing SQL Server RDBMS.
Both methods given in the above answers will work. I have tried them both. However using a
db generation script reduces the size of the final deployment files considerably. I would launch the script on the first run of the application and not in the setup itself.
I will second jack on this one.
From my experience of using installs that require an actual database file tend to have more issues then when updating or on first install when running scripts. As jack mentioned another bonus is reduced file size.
You can create who database scripts by right clicking on the required database, and selecting the script database option. Note however this will only create the tables and fields and not replicate any data.