The JPA Buddy Reverse Engineering tool is not showing tables - mysql

When I click from "Entities from DB" it correctly connects to DB, and it succesfully performs the introspection, so that I can see the list of tables from the side view. But within the popup I get 0 tables, 0 views and 0 mapped relations
0tables
I tried disabling cache and change some settings, and also restarting, but with no luck.
How can I solve the problem?

For MySQL, you need to explicitly specify the schema name in the connection string to make JPA Buddy work. 
Even though IntelliJ IDEA allows you to create a data source without specifying a target schema or even a database, JPA Buddy can only get data from an explicitly specified connection string. This limitation comes from the fact that we use JDBC driver to obtain meta information. So, in case your tables are located in the non-default schema, you need to create a new connection targeting the database and schema, as explained here https://www.jpa-buddy.com/documentation/database-connections/#non-default-schema-connection.

Related

When writing data to a linked table in Access, what actually does the writing?

If I have a tool that writes data to Access but one of the tables is a linked table, how exactly is the data written to that linked table? Does the data get off-handed to Access and then within Access, Access handles the writing of the data? Or is a kind of link provided to the tool and then the tool writes directly to the table?
The reason for asking is that I've encountered times where some automated tools that I work with will or won't write to a linked table and I'm curious of how to ensure that data is always written.
Usually, all data is written via the Access Database Engine, unless you're doing something weird.
In most situations, it works like this:
Tool submits a query via OLEDB/ODBC/DAO to the Access Database Engine (DAO360.DLL/ACEDAO.DLL)
Access Database Engine determines which data should be read/written to where (to the file/remote data source)
Access Database Engine uses the connect property of the linked table to try and open a connection if necessary, and creates a new query or multiple queries in the appropriate SQL dialect
Access Database Engine submits query/queries via the opened connection
However, this can go wrong:
The tool doesn't actually use the Access Database Engine at all, but tries to directly write the file (via UCanAccess/MDBTools/proprietary driver), and those don't support linked connections at all
The connection string in the linked table requires an ODBC driver, password, resource, or something else that's not present or not in the right place
The linked table requires some sort of implicit authentication (e.g. SharePoint), and this doesn't happen
The data source used by the linked table requires a specific lock type (e.g. dbSeeChanges for opening a Dynaset-type recordset on SQL server) which is not used by the tool
And of course, many, many more things can go wrong (in fact, I crashed Excel in an attempt to test reading a linked SharePoint lists while writing this answer).

BIRT report database set as parameter, but parameter requires the database?

I have a feeling I'm in a catch-22 situation here, but I'm posting in the hope someone has found a workaround for this at least!
The database for the BIRT reports I work on is being passed in via a hidden parameter called db, so in the data source of my report. So under Property Binding, I tell BIRT to use "jdbc:mysql://localhost/" + params["db"].value as the JDBC Driver URL. This is supposed to use the database name passed in from the URL at runtime in browser, a solution I found online to account for running our reports on computers with different database names.
My issue is that in the same report parameters, the user has to select a company from a list of companies which come from the database. But the report can't populate this list because the database isn't loaded until I press OK on the parameters window, which can't be done until they select a company, and uh-oh I found myself with a catch-22 situation!
I have no idea what I'm suppose to do in this situation, how can I get the report to load the database first, then display the parameters screen based on it?
As far as i know we can't do this because there is no dependency mechanism between two report parameters in BIRT, except cascaded parameters. In this case it means the selected value of parameter "db" is never available when the list of items of "Company" is being evaluated.
Therefore the database should be provided using a different approach. You have a couple options here:
Option 1: Session attribute (if you make use of an application server)
Store the selected database in a user session attribute, and then retrieve it in the property binding of the JDBC URL with an expression such:
reportContext.getHttpServletRequest().getSession().getAttribute("db");
Advantage 1: the database can be different for each user
Advantage 2: the database can be dynamically changed for each user
Drawback: Requires to develop a small servlet allowing to select the database and store it in user session
Option 2: Connection Pool (if you make use of an application server)
This should always be the favorite way to access a JDBC datasource with BIRT. We just have to fill a JNDI URL in the datasource (see your first screen above). The physical database URL and credentials are defined on each application server in a connection pool.
Advantage 1: completely native, nothing specific to be developed
Advantage 2: connection pooling are much more efficient than direct-access JDBC
Advantage 3: connection pooling prevents "Too many connections" issues
Advantage 4: we don't have to hard-code database URL & credentials in reports
Drawback: This JNDI URL is shared by all users.
Visit this article to see an example of using a connection pool with BIRT.
Option 3: Externalize DB in Properties file
As you mentionned database informations can also be externalized in a file.
Advantage 1: we don't have to hard-code database URL & credentials in reports
Advantage 2: we can also develop a small servlet to update this properties file through a GUI
Drawback: This database is shared by all users.
Please check this topic to see how to access a properties file through resources of a report
Option 4: Connection profile store
Advantage: we don't have to hard-code database URL & credentials in reports
Drawback: This database is shared by all users.
Please check this topic to see how to define a connection store
Answering my own question here for the benefit of others. The best solution to this problem is to use an external connection profile property file as described on this stackoverflow thread link. This didn't work for us originally because I couldn't work out how to make the report file look for the properties file regardless of the computer it was run on. However I discovered it is possible to specify an absolute path when loading/saving the properties file (For BIRT 4.4.0 this is under the drop-down beside the browse button under the connection profile of the data source). This allows the the file to be read on any computer once it is saved under the same absolute path.
The other important thing to note is BIRT has a weird habit of changing which of the 3 methods of loading a data source it will use. During our testing we found that if we didn't leave the property bindings settings blank when using a connection profile, BIRT appeared to randomly choose to load via parameter or load via properties file based on which was edited last, very confusing!
Using a parameter to specify the database is still possible, it just has very limited usage. It worked for us up until this point because while we had the database set as a parameter, the same database was always set in the JDBC which the report used to populate the company parameter. But we no longer want to have to set that database manually, now it will be loaded automatically with no problems (hopefully!).

Read similar tables from multiple MySQL databases using WS02

We got an application wherein multi-tenancy is implemented by having a unique database (MYSQL) for each tenant. The table structures are the same. I got a requirement to list all expiring products for each of the tenants, and I was wondering how can I incorporate all those in one data web service in WSO2? I know that I can create a query with the database prefixing the table:
eg. select DB1.products.id, DB1.products.name from DB1.products
Do I need to define a data source for each database (100+ tenants), and can I specify the database name as an input variable in the data service operation? ie. select ?.products.id, ?.products.name from ?.products
Thank you for your help.
Cheers,
Erwin
If your intention is to have a generic data service that would retrieve those tenant specific information from those database dedicated to each tenant, as I see, the most cleanest way to achieve this would be by generifying your SQL queries and making the used datasource dynamically discoverable.
Since you're using 100+ tenants(WOW that's a huge number :)) obviously you might be having 100+ databases created for those tenants too. So, you would need to create a carbon datasource with the same name in each tenant (let's say "testDS") wrapping the tenant specific database configurations such as JDBC URL, credentials, etc. Next, if you've come up with your dataservice configuring the used datasource to be the aforementioned datasource, at runtime, it would correctly pick up the appropriate tenant specific datasource as the datasource feature completely supports multi tenancy. That would prevent you from passing the database name, etc to the SQL query and make your data service configuration more clean, generic thereby making it more maintainable.

Stop EF Database Initialization for DefaultMembershipProvider

Team, I have an ASP.NET MVC application that I'm deploying. When I deploy it the application works fine, but when I call Membership.CreateUser it ends up trying to create the database even though it already exists. What do I need to do to get it so that it will not try to call CreateMembershipEntities since the database already exists?
I've tried Database.SetInitializer to an initializer that does nothing, I've tried removing the defaultConnectionFactory in the Web.config - I'm currently out of options.
I look forward to your help!
UPDATE
I just found out yesterday that the reason it's trying to create the database is because the hosts servers do not allow the connection to query sysdatabases and so the database never exists and is hence always trying to create it. It appears that I may have to go back to the old fashioned AspNet membership provider and also go away from the EF code first model.
give a look here: http://www.qualitydata.com/learn/web-config-membership-provider-settings
It shows the Membership configuration section of the web.config. You have to write a similar section and put connectionStringName="Your Connection String". In your connection string you specify the informations of the already existing database.

Entity Framework 4.1: Code first error: "the model backing the context has changed since the database was created"

Im creating a database via a "code first" application, the sql server contains no databases.
The application runs fine, creates the database and seeds the data i have defined in my initializer.
a service i have running tries to add some data to the database for the first time. i get the error:
The model backing the 'yyyContext' context has changed since the database was created. Either manually delete/update the database, or call Database.SetInitializer with an IDatabaseInitializer instance. For example, the DropCreateDatabaseIfModelChanges strategy will automatically delete and recreate the database, and optionally seed it with new data.
There should be no changes since the database was created and when then service runs.
I'm running EF4.1, and the database doesn't exist so unlike questions with similar titles:
Database.SetInitializer<YourContext>(null);
Isn't the solution for me.
Any ideas about what could be wrong are welcome.
Doh! moment, turns out the service wasnt using the same connectionstring as the other app.
the reason the databases didnt look the same must be because earlier in development i started the main app with no connectionstring aswell, so it provisioned a local instance database for itself to use.
Then later when i was trying to use the service, it was trying to access the same database from earlier, and the model changed significantly since then.
I pointed the connectionstring to the correct database and everything worked from there.