I have a Java aplication that retrieves data from SQL server.
The queries are of the form
SELECT field1, field2...
FROM [PRODUCTION].[INNOVATOR].[someTable]
WHERE NOT date = ''
This works fine.
However, I created for a user dedicated view, that has quite complex structure, including multiple JOINs.
I want to retrieve data from this view while avoiding the debug of this SQL in the Java environment.
So, I placed the name of the view instead of someTable.
Sound simple, but I get constantly an error message saying that the is not found.
Any idea why?
Check who the owner of the newly created view is. Since the fully qualified name of a view is Database.Owner.View, the query above will only work if the view owner is "INNOVATOR". Replace "INNOVATOR" with the view owner.
Related
I have JDBC Connection to my cloud MySQL database.
Utilizing the benefit of View's fetch time, I decided to create view for my user-queried searched results to be added into my JavaFX UI TableView.
I have following SQL View to run from method in UI.
CREATE VIEW `SEARCHED_QUERY_VIEW` AS
SELECT PRODUCTS.id,
PRODUCTS.name AS 'Product name',
MANUFACTURER.name AS 'Manufacturer name',
PACKAGE.name AS 'Package type',
SUB_PACKAGE.name AS 'Sub Package type'
FROM LOGISTICS.PRODUCTS
JOIN MANUFACTURER ON PRODUCTS.manid = MANUFACTURER.id
JOIN PACKAGE ON PRODUCTS.packageid = PACKAGE.id
JOIN SUB_PACKAGE ON PRODUCTS.subpackageid = SUB_PACKAGE.id
WHERE MANUFACTURER.name LIKE '%VIT%' OR PRODUCTS.name LIKE '%VIT%';
Now the problem lies with LIKE here.
I want LIKE to get an argument which will be passed from a parameterized method in JavaFX.
Can anybody advise solution on how to rework the view to receive custom LIKE parameter from Java Method?
You should move like parameter to select from the View.
So create the View without like condition but use LIKE in the query:
SELECT * FROM SEARCHED_QUERY_VIEW WHERE `Manufacturer name` LIKE '%VIT%' OR `Product name` LIKE '%VIT%';
I'm trying to make custom spring Data query using field from reference as query
parameter. When i performed this query via REST i had no results at all:
I enabled hibernate logs and copy it to H2 console and I got many results:
My Flight and Airport entities are very simple
So what am I doing wrong? I have other simpler methods and they work fine using browser. I tried the same using Query annotation(second method on second screen), but I got same results. (Copied generated sql query to H2 console and received many results but it didn't work via REST).
EDIT
I found the solution. I just removed quotation marks from URL and
it works well :D
Sorry for my inattention.
Regards,
Michal
I found the solution. It was very simple. Basically I just removed quotation marks from URL and it works well :D
Actual method in Repository looks like:
List findFlightsByFromCityAndToCity(#Param("from") String from, #Param("to") String to);
Regards,
Michal
I am getting familiar with Java through involvement on a servlet web service project that is now up and running. But the stakeholders want a front end that will allow them to examine the audit table set up in a SQL server database. I am trying to quickly put one together in JSP with initial success but now stuck.
I want a drop down list to provide a list of all the users (Unique). I have acheived this using a JSTL taglib method following the link below with the following SQL;
"SELECT DISTINCT(USER_ID) FROM AUDIT_MESSAGE".
http://www.apekshit.com/t/205/JSTL-SQL-Query-Tag-Example
Now I want, when the user clicks on one of the users names it automatically populates another drop down list with a list of times that user logged in with the following SQL;
SELECT SESSION_ID, EventTIME FROM dbo.AUDIT_MESSAGE
WHERE OPERATION = 'loginResponse' AND RESULTS = 'OK'
AND USER_ID = 'firstdropdownlistselection'
Then when an item from the second drop down list option is selected a third SQL statement of;
Select * FROM dbo.AUDIT_MESSAGE
WHERE SESSION_ID = 'seconddropdownlistselection'
This is then used to populate a list box of the Users events at the selected time.
I have found the following link below offering another method but I am unsure whether to continue with the method I have started with or is there a better way. Can someone please advise me on what method would work best?
Multiple ResultSets
Thanks in advance
AJF
You could display the whole database table information(minus the ids) if this is what they want.
If you want to do it in these steps (select user, select session, display information) what you are doing is correct.
I created a web service using wso2 data service. But when I try to test it it gives below error.
Below is the screenshot of the error.
You are getting this error, because you haven't defined the result of your select query. When you define a SELECT query, you are going to retrieve a resultset from the query. So you need to define the result using the output parameters.
In the Add Query page there is a section called 'Result (Output Mapping)' where you can define the resut.
Alternatively you can define the query with column names (ex: SELECT name, age from Student) and then just click on 'Generate Responses' which automatically generate the response[1].
[1]http://docs.wso2.org/display/DSS301/Generate+Response
Question::
How can i pass the value to parameter named “userParameter” in a query. using requestScope
Kindly help out with the steps to make a request scope work on the same page.
For now I know the following.
I have a page named UserRoomReservation
I have a data control (UserView)
Drag the first data control as a table.
convert the first column to a link
add actionlistener to that link
from: #{row.userId}
to: #{requestScope.userParameter}
I created another view object via sql query
I put a named parameter ":userParameter"
the sql query is as written below:::
SELECT DISTINCT Fullreservation.USERID,
Meetingrooms."roomName",
Meetingrooms."roomId" ,
COUNT (Fullreservation.roomid) AS countRoomUsage
FROM FULLRESERVATION Fullreservation, "meetingRooms" Meetingrooms
WHERE fullreservation.roomid = Meetingrooms."roomId"
AND Fullreservation.USERID = :userParameter
GROUP BY
Meetingrooms."roomName",
Meetingrooms."roomId",
Fullreservation.USERID
I dragged it to the same page as a graph.
but it doesn't work because the value hasn't been passed to the
You can get value from requestScope
ADFContext.getCurrent().getRequestScope().get(obj);
and then set this value in bind variable using NamedWhereClauseParam method
ViewObjectInstance.setNamedWhereClauseParam("BindVariabbleName",value);
ViewObjectInstance.executeQuery();