Java Oracle Sql statement not performing [closed] - java

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
Hey I am trying to run a java program in a Oracle sql load.sql file. Whilerunning the program I am getting the error "ORA-00920: invalid relational operator ". I think the issue is in where I prepare the sql statement and trying to execute it. I am trying to get information out from two sql tables: a2_loan and a2_customer. In a2_loan i want to get the loan_num and the contract_date, while in the table a2_customer I want the name and the ird_num. My statement is currently:
String sql = "select a.name, ird_num, loan_num, contract_date from a2_loan a, a2_customer b where a.name=b.name and b.name";
I think it is in here that the problem lies but if it is somewhere else please tell me and I will copy the rest of my code!
I want to be getting the loan_num and contract_date out of the table a2_loan
And the name and ird_num out of the table a2_customer

Your query, slightly reformatted, is
select a.name, ird_num, loan_num, contract_date
from a2_loan a,
a2_customer b
where a.name=b.name
and b.name
The problem is in the last line. and b.name - what? and b.name = something? We can't tell from your query what you're trying to do, but in the last line you must compare b.name to something, or else you need to get rid of the entire last line.
Best of luck.

Related

Error Java Stream has already been closed [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 days ago.
Improve this question
I have code bellow mapped in Entity:
#Formula("(select c.cd_company from table_2 c where c.id = idTable2)")
private Integer company;
When execute code ocurred error:
o.h.e.j.s.SqlExceptionHelper:SqlExceptionHelper [http-bio-50001-exec-2] SQL Error: 17027, SQLState: 99999
o.h.e.j.s.SqlExceptionHelper:SqlExceptionHelper [http-bio-50001-exec-2] Stream has already been closed
But, if i change "company" to other name, for example, "ompany", its work normally without errors
execution query with success

How to override duplicate keys in Java Map [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I have this as my query.
select a.cust_id,a.cust_name,b.cust_id,b.cust_name
from acustomer a,bcustomer b
DaoImp using Spring NamedJdbcparameterTemplate
method:
NamedJdbcparameterTemplate temp= new NJPT(datasource);
List<Map<String,Object>> out=temp.quertForList(query,parametermap);
But the problem is that whenever I get the output for this query in db tool, I get 4 columns but in program output I am only getting 2 columns, i.e cust_id and cust_name of a is getting overridden by b due to same key name in Map.
How can I fix this, please note the query will be different each time as I am using this method as a general one for my program and output will be a list of values, so cannot map any model class for the output.
Please note I want this function to be generic one which means the query will be changing each time and output will be of different types.
Well the easy solution would be to give your fields aliases, so that their keys would be different.
select a.cust_id a_cust_id, a.cust_name a_cust_name, b.cust_id b_cust_id, b.cust_name b_cust_name
from acustomer a, bcustomer b
where a.cust_id=b.cust_id
Then in the map you would find the aliases, a_cust_id, a_cust_name, b_cust_id, b_cust_name.

Is there something wrong with my query? Am I using Inner Join wrongly? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I could use some assistance with my exam project, I have a problem with my SQL query for getting a list of volunteers(id) based on the guild(s)(id) they're in, it is a many to many relationship and have decided to use 'Inner Join' to tell my java program what id's are = to each other, but when I run it, it gives me the error 'com.microsoft.sqlserver.jdbc.SQLServerException: The index 1 is out of range.' Which supposedely means that the list I am trying to show is empty? Any immediate thoughts?
This is the many to many relationship between the 3 tables in diagram:
The query to get the volunteer based on guild, first time using the Inner Join statement, so there might be an error here I have overlooked,
Looks like you need some more spaces at the beginning/end of your strings that you are concatenating.
You also need to select columns using a comma between them, not and.
e.g. select firstname, lastname ... instead of select firstname and lastname ...
The '?' in the WHERE statement is considered a String in SQL, and since there were no GuildName with the string 'questionmark' it tried to find a string in the GuildName column where there was non which resulted in an empty list. Also the concatenation of the strings were incorrect since there was no spacing between Volunteer and Inner. Fixed it. Thanks for the replies.

Java Statement.executeQuery SQL error with ORDER BY and/or LIMIT- not sure what the correct format [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I'm trying to get a result set out of a JDBC database using Statement.executeQuery. It needs to be ordered by the first column, and limited to 1000 rows. Right now, the sql statement I'm using is as follows:
SELECT * FROM TABLENAME ORDER BY COLUMN1NAME LIMIT 1000;
This is just giving me SQL errors. There's clearly something wrong, but I don't really know sql well enough to figure it out.
The database is Postgres.
It would be better if you use Statement#getMaxRows instead and let your JDBC driver manages this (if supported):
final int MAX_ROWS = 1000;
//...
String sql = "SELECT * FROM TABLENAME ORDER BY COLUMN1NAME";
Statement stmt = connection.createStatement();
stmt.setMaxRows(MAX_ROWS);
ResultSet rs = stmt.executeQuery(sql);
Otherwise, provide the specific database engine you're working with and use the proper statements.
Never mind, it's not the syntax. The column name was being retrieved from the wrong resultset. Sorry.

The positional input parameter ''{0}'' cannot use non-Integer characters [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I am facing the following probleme in my JPA Entity during the runtime.
"The positional input parameter ''{0}'' cannot use non-Integer characters"
JPA CODE:
#NamedQuery(name = "tableName.findMenueByBenutzerIDAndMandatID",
query = "select m from DOMenueVerwaltung m " + " where m.menue=?EN"),
What can be the cause of this?
Thanks for any suggestion
JPQL supports either named parameters (":myParam") or numbered parameters ("?1", "?2"). What you have there is neither (a question mark symbolising numbered parameter, but with a name after rather than number). Suggest reading any decent JPA docs

Categories

Resources