How to fix error "Cannot resolve column..." - mysql

I am developing Java web application what based on Spring Framework, MySQL, JPA. I have a problem when try to persistence data from HTML form to SQL database, then I try to debug and fix. I am using IntelliJ IDEA Ultimate 2017.1. I catch error:
Cannot resolve column 'product_name' This inspection controls whether
the Persistence ORM annotations are checked against configured
Datasources
This is screenshot:
How to fix it?

For those who just want to disable this check, go to
Intellij IDEA -> Preferences -> Search "Unresolved database references in annotations" and uncheck it.
(macOS Mojave and Intellij Ultimate 2019.3)
This will disable the inspection and remove all the "Cannot resolve column…" errors on the #Column annotations. Intellij will stop checking if the String column names exist in the database tables. Do it at your own risk.

Open Persistence tool windows, right click on module, then set DataSource. IntelliJ IDEA will validate source code by real SQL database.

You have to manage your data sources. I followed the steps detailed here
https://www.jetbrains.com/help/pycharm/managing-data-sources.html.
In my case, I did the following (I am using Pycharms, but I assume the process is similar for other Jetbrains IDEs):
Bring the Data sources and drivers window by going to view > tool windows > database
Click the wrench icon to configure the db connection
Configure it, and try that the connection works with Test Connection
Pycharms should now autocomplete fields in the db.
If it still doesn't work:
try restarting Pycharms.
go to options (command + ,), then search for SQL, select menu SQL Resolution Scopes, and try adding a scope by clicking +, then selecting your current project folder as path, and your db as the resolution scope

I found a TEMPORARY work around for this bug.
Please before you follow my workaround do exactly what #Benjamin Crouzier's answer suggests. THEN, go to any of the unresolved columns, right click it and they click execute. and Boom annoying warning SOLVED :)

After trying all the solutions above, I solved this by clicking Refresh in the database tool window.

Related

How can execute flexible search on japers reports?

I'm beginner in hybris. I need to create a jasper reports, using flexible search and mysql server. But I can only use the sql query statement without flexible search in report file (Jrxml source file (.jrxml)).
How can I using the flexible search with mysql?
Are you following the guide provided in Hybris Help for building a custom report? It can be found at https://help.hybris.com/6.3.0/hcd/8b6e40ee86691014b99eda29aebc9d84.html
In the interest of having a source of information in case the link ever becomes dead:
Go to ${HYBRIS_DIR}/hybris/bin/platform
setantenv.bat for Windows or . ./setantenv.sh for Unix/Linux
Go to ${HYBRIS_DIR}/hybris/bin/ext-platform-optional/virtualjdbc
Run the ant command ant dist
Go to ${HYBRIS_DIR}/hybris/temp/hybris/virtualjdbc. You should have two files that have been generated here, hybris-virtualjdbc.jar and vjdbc.jar
You now need to copy these two files to ${HYBRIS_DIR}/hybris/bin/ext-platform-optional/virtualjdbc/lib
Download the Jaspersoft Studio Tool at http://community.jaspersoft.com/project/jaspersoft-studio
Install and Open Jaspersoft Studio
Go to Tools > Options > iReport > Classpath
Click Add JAR twice, each time selecting one of the newly copied JAR files (hybris-virtualjdbc.jar and vjdbc.jar)
Click OK
You now need to setup the Data Source, to do this:
Click on the Report Datasource icon ()
In the newly opened window, click New
Select Database JDBC Connection and click Next
On the next screen you may provide any name for your JDBC Connection
In the JDBC Driver field, make sure you type de.hybris.vjdbc.VirtualDriver
In the JDBC URL field, make sure you type jdbc:hybris:sql:http:///virtualjdbc/service, where is the location of your application server (e.g. https://localhost:9002). Remember this will change with each environment!
Provide a Hybris User for the Username and Password. It may be worth using the admin user to begin with, but make sure you lock it down at a later stage to a user with less access, such as vjdbcReportsUser
Test the connection. Remember you will need the server up and running to be able to use vjdbc
From here onwards, you should be able to create a report using Flexible Search style syntax!

Unable to resolve valid table in PhpStorm

I'm getting unable to resolve table errors appear in php files containing SQL querying valid tables.
If I Ctrl + Enter over the query, then I get expected results in the DB console, and if I expand the database in the DB explorer tab then I can see the tables.
It's not affecting code execution, but it's annoying because it catches my eye when writing code, and it masks real SQL errors.
I've tried refreshing the database connection, and I've verified that the php tab is connecting to the correct database.
In 2017.2 I had to go to
Settings > Languages & Frameworks > SQL Resolution Scopes
and add my project and database link in there to get it right again.
Try re-creating DB connection from scratch (delete existing one and create it again).
Thinking of possible reasons ... I can think of this scenario:
working with project in current stable version (currently 2016.1.x);
trying EAP build for next version (2016.2 at this moment) on this project and make some DB-related changes there (even simple syncing DB);
going back to stable version (2016.1.x) .. and because new version uses newer file format/versioning for DB-related data (cached DB structure etc) IDE may start ignoring "unknown/newer" format for such data and instead of throwing appropriate warning it just "silently" throwing "unresolved table" message.
No other ideas.
I was getting what OP was getting, and the problem was my DB Server was MariaDB and i had MySQL selected as the SQL Dialect.
See File > Settings: Languages & Frameworks > SQL Dialects.
Faulty error pollution DRIVES ME NUTS TOO!
If I start having SQL resolution issues, I will check my resolution scopes (settings -> Languages & Frameworks -> SQL Resolution Scopes).
Generally I have the most issues when my project mapping is set to 'All Data Sources' by default.
The following steps always fixes it for me:
Click the Project Mapping Dropdown
Uncheck the global 'All Data Sources' setting (required to make other selection available)
Click the drop down arrow for your Database connection
Check 'All Schemas' (Or Specific Tables)
Click OK to close the settings window
Your false resolution errors should disappear after the next parse cycle.
You aren't limited to applying the above steps to just one DB connection, you can do it for all connections in your project.
Sometimes adding a custom resolution scope will work as well, but it is hit or miss for me.
Click the plus sign (top right)
Select the file you are working on and hit 'OK'
Select the 'Resolution Scope' column
Deselect 'all data sources'
Select the specific DB resources you want
Reconnecting to the DB never works for me.
Specifying the table works well... but it can become very cumbersome as the project grows.
I have also run into an additional situation where PHPStorm would only resolve some of my queries, no matter what scope resolution settings I used. However, after I attached a console to my file, they resolved just fine.
(Search for 'Attach Console' in Help | Find Action. You can also add it to a 'Quick List' or Keymap it.)
Although this answer is specifically for phpstorm, I had this same issue in IntelliJ and none of the above fixes worked for me. I had my scope added, everything was active. I could query the database in the console window perfectly fine, and I was totally stumped.
Eventually, I noticed some text in the database panel that said 0 of 4 in tiny text. It looked like this:
Upon clicking on the 0 of 4 text, I discovered there were no schemas added to the connection, even though a default database was set upon making the connection originally. Going to that page allows you to add schemas. Be sure to either select "All schemas", "Current schema", or the specific database that you want to use with your connection.
Changed dialect to MariaDB on global and project level.
OR
To dismiss this error in PHPStorm versions before 2017 which have no SQL Resolution Scopes option:
Go to File
Go to Settings...
Go to Editor and then Inspections
In SQL chapter uncheck Unresolved reference
Click Apply and then OK
Adding database name before the table name worked in my case.
For instance, instead of writing SELECT * FROM Client, put SELECT * FROM database.Client.
I will add another answer, because for me, it was a completely different (embarrassing) cause:
I somehow forgot to add the database name in the data sources general settings (where you also set the host, user and password).
In my case, I have clicked the right button in the SQLScript and change the Dialect to "Generic SQL". It worked for me.
I solved this problem as follows:
CTRL + SHIFT + F10
new query console
Write a selection query to the database, for example:
SELECT * FROM user WHERE user_email='$email' AND user_password='$password'
Enter your code page and click on the table name in the query
ALT + ENTER
run query in console
Select the console you created
First, you need to check the Schemas tab, and make sure you've added the database.
If the unable to resolve table error stills appears, there're two options to fix this:
1.You can edit the properties of the Data Source and add the name of Database, then you can see that select * from table works well.
2.On the other hand, you can also use sql like this select * from database.table. It works for me.
By the way, in many situations, autocomplete can be very useful.
[PHPSTORM]I solved this problem by setting
Languages&Features
SQL Dialect
adding your current file into path and modify its SQL Dialect as a server you are using.
NOTICE!!!!! mine is MySQL but it is exactly MySQL causing problems, after switching into [generic SQL] PROBLEM SOLVED!!!

What contract am I not specifying?

When I try to run my Windows Store app, it won't, and shows me this:
..."does not support the contract specified"? What contract? I'm not implementing any contract; I assume it means the Settings contract or some such, but I'm not doing any of those yet.
I went to the Help page suggested, and it says, in part, "To diagnose these errors
There are no sure ways to fix these errors. Use these techniques to diagnose the problem."
The first suggestion is:
Open Event Viewer (on the Windows Start menu, search for Event Viewer.) In Event Viewer, navigate in the tree to the Application and Services Log\Microsoft\Windows\Apps folder.
Filter the view to event Ids: 5900-6000
Examine the log and see what occurred.
Windows 8.1 only brings up web pages when I search for "Event Viewer"
Actually, I did write a utility to catch event logs, and I ran that. I found these:
***Type: Error
Source: Microsoft-Windows-Immersive-Shell
Time Generated: 11/27/2014 15:10:39
Message: Activation of app App.adaf78a74.a8c80.a4ff5.a99ca.a97636d548196_8wekyb3d8bbwe!Designer.App failed with error: -2144927148 See the Microsoft-Windows-TWinUI/Operational log for additional information.
Type: Error
Source: Microsoft-Windows-Immersive-Shell
Time Generated: 11/27/2014 15:20:08
Message: Activation of app axXAndSpace.Visits_qtyjefqf75sa6!App failed with error: -2144927148 See the Microsoft-Windows-TWinUI/Operational log for additional information.***
But where is "Microsoft-Windows-TWinUI/Operational log"?
The second suggestion on the Help page was:
Use the native debugger
Configure the project to run under a native debugger.
In Visual Studio, set the Debugger Type to Native Only on the Debug (Debugging in C++ and JavaScript) page of the property pages of the start-up project.
Look at the exceptions being thrown by looking at the output window. You might want to configure the debugger to stop when these exceptions are thrown.
I did that, but it gave me no more information than previously - nothing at all displays in the Output pane.
What could be the cause of this?
UPDATE
Just to update the progress:
Based on Iris Classon's suggestions, I went to Control Panel to see if my app was installed so that I could uninstall it, but it's not in that list.
If I search for the app by typing its name, it tries to start up - its splash screen displays, but goes no further than that.
I went to Program Files\WindowsApps, and when selecting it got, "You don't currently have persimmons to access this folder, click continue to continually get access"
That leads me to "You have been denied permission to access this folder; to gain access to this folder, you will need to use the security tab"
Click the "security tab" link takes me to that tab, and a "For special permissions or advanced settings, click Advanced"
I do so.
That takes me to a Permissions tab, which says, "You must have Read permissions to view the properties of this object; Click continue to attempt the operation with administrative permissions"
I then selected (one at a time, as that is all it allows):
Trusted Installer : Full control
System: Read, Write, and Execute
System: Full Control
Administrators: Read & Execute
But so far, none of that seems to do anything good.
UPDATE 2
This problem has just "gone away" today; I don't think it was anything I did. I added a UserControl, tried running the app again, and now it runs - I don't see that error message. However, I do see a seemingly unrelated one. (at least I got further).
I just had this problem on a fresh install of Windows 8.1 on my laptop. I'm not sure which one of these steps solved it, but until somebody can give you a more exact answer here is something to try as I am sure you are keen on coding.
Only Store Apps run from VS gives that error, other Store apps work fine.
I first of all changed permissions on my WindowsApps folder under Program Files and made sure that I had full access to the folder and sub folders. Restarted the laptop, still no luck.
Then I set up an admin guest account (just something I tend to do for when I need to record tutorials- so not related to trying to solve the error). Out of curiosity I tried to create and run the same Windows Store App and got an error that another user had installed the app. Strange, how was it installed if it gave me the error that it couldn't activate the app on the main account?
I logged back in as the main user and uninstalled the application (which was showing up as installed), and I can now run any Store App from VS without problems.
Not sure this is an answer since I'm not sure what made it work, but give it a try and hopefully somebody else can clear this us up. I'll investigate further, but I'm on a train right now with poor WiFi connection :)
Best of luck!
I had the same scenario, here are the steps I did to resolve:
I tried to create packages, chose not to associate with the store.
It said that the certificate is expired, I created a new test certificate.
I created the test packages successfully.
Tried to run the project from VS and it finally ran.
I believe all of this had to do with the certificate. very frustrating and time wasting issue.
I also had the same problem and following steps fixed it. Hope it will help some one else.
Open the appxmanifest file
Go to "Packaging" tab
Select "Choose Certificate" and select "Pick from certificate store" and select your cetificate and click on ok

MySQL Workbench: How can I see the detailed SQL query and errors when I use the "Apply" button? (confirmation popup)

I recently upgraded from MySQL Workbench 5.2.47 up to 6.1.
After making changes to a table via the Gui grid interface on the old version, I'd hit the 'Apply' button and have a popup confirming to make the change. This popup had the SQL code that would run in order to make the change that I made via the UI interface. I would then confirm the action and get a success or failure popup. If a an error occurred, I could see the detailed error in order to easily troubleshoot the problem.
With the new version, I make a change in the GUI interface and hit the 'Apply' button. No confirmation popup, it just executes. The result is a small snippet in output window. This is fine unless there's an error, in which case it has a very generic message. "1 error(s) saving changes to table XYZ". I have not found how to access the detailed error message, either by right clicking the row or looking in the preferences.
So, how do I get the popup confirmation with SQL query and error messaging to work in the new version or, at the very least, be able to see detailed SQL query error details?
Functionality restored in CE release: 6.1.7
http://dev.mysql.com/downloads/file.php?id=452662
It is indeed a bug :-(
In the MySQL bug database:
http://bugs.mysql.com/bug.php?id=72169
http://bugs.mysql.com/bug.php?id=72155
Until they don't fix the bug you can try to close the Query Tab. When it asks if you want Save the Changes or Not, you choose Save and then it shows the detailed errors :)

New LightSwitch Project

I have started a new Lightswitch project using a SQL database that was created with Lightswitch. When I publish and install the new Desktop project everything goes fine with no errors in publishing, installing or loading the new application. The first and only screen appears. I can click on different records and the data shows up and I can edit the data. However, if I use the list search function all of the fields get Red x'd.
The original application works the way it supposed to work.
I have tried with and without IIS: Published with (local) and (IIS) and get the same results with both methods.
The connecection string options for the new app are not the same as the original in that System Admin and Sytem user connecection strings are not offered so it is difficult to know if I replicating a working setup or not.
In Mananagement Studio I am awash in security, permissions, roles, and login selecitons. It seems clear that this is permission level problem but I have no idea on where to start trouble shooting.
see:
Diagnosing Problems in a Deployed 3-Tier LightSwitch Application
http://blogs.msdn.com/b/lightswitch/archive/2011/09/20/diagnosing-problems-in-a-deployed-lightswitch-application-eric-erhardt.aspx
How many string properties are in the table that you're displaying? Is there a large number of properties that don't need to be included in the search?
This forum post discusses the same issue as you're encountering: Search returns error "Unable to load data" with a Red X
Have you checked your connection string setup? I do have those issues back when I was using SQL Express on development and using SQL Server Enterprise as my target database server.