Add tables to the database on cloudbees or run .sql file for database in cloudbees - 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.

Related

How to rename a Linked Service in ADF

I am new to ADF and need some help please.
I created a Linked service for a sql database. I know need to make this dynamic (I know how to do this). I also want to rename the Linked service to reflect this dynamic nature. But I cannot find a way to do this.
Can someone help please? Not many hits in a google search
Thank you
I'm pretty sure you can't rename a Linked Service after it is published. If you want to dynamically create a linked service I would suggest building a small script using the SDK:s that are available like the ArtifactsClient from azure-synapse-artifacts for Python if you're running in Synapse Analytics Data Factory. You might then want to create a Linked Service for each run and tear it down after you've ran your pipelines. There should be an SDK for this in the "regular" Data Factory as well.
EDIT: Just noticed that there's a function for renaming a linked service through the mentioned API. See documentation here.
If your ADF is linked to GIT you can follow these simple steps to rename your linked Service:
Clone your ADF locally
Create a new branch (optionally)
Open ADF code in any Editor and Search and replace Linked Service name in all files (I use VSCode)
Rename Linked Service file name to new name (If not done ADF will prompt an issue)
Commit and push your changes
Verify on ADF (don't forget to switch branch)
Create a pull request to merge your changes to your main branch

Cloud bees, create db's tables

After I've done developing my web site using Hibernate and Struts2, now I want to put it on Cloudbees hoster, the problem is that I don't know how to create my data base's tables?!!
I used the method shown in this video to create my tables: http://vimeo.com/33445098 But it doesn't work!!
It shows how to connect to my server by using MySQL WorkBench, when I created new Server instance the connection couldn't be established, although I used the appropriate informations.
Thank very much :)
After days of looking around on the web I found this, it's very useful
http://www.youtube.com/watch?v=oWE6s_FQBwA

Creating database (not populating it) through Ant build file

I've managed to do some ant-script to populate my databases.. (simple script that runs some .sql files, like 'create', 'populate', 'drop', etc.)
Is there any way in hell that an ant-script can create the database itself from scratch? This is for JavaDB-Derby (from the glassfish bundle). Since it's a project for university, we find that we recreate the database on different machines all the time, and I would like to avoid this. Also it'd be great to know.
Normally I would create a database through Netbeans, and it would ask for a name, location, username, and then it would create the link derby:jdbc://localhost:1527//DBUsername/
I understand this is probably a bit too db-related, but since ant seems like a good tool maybe it could help.. or if not, maybe some other way (maybe another .sql file?)
Thanks for any replies.
Apache Derby's JDBC driver lets you create a database using ;create=true flag in the connection string:
jdbc:derby:MyDatabase;create=true
You can do this from Ant by running ij tool as command-line (or as java app). Here's a link to documentation
I've created databases via Ant. I don't recall having a problem executing DDL with the SQL task. You might want to check out DBUnit.

SQL table not created when deploying a WAR file to Liferay

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.

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.