my sql and java [closed] - java

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 6 years ago.
Improve this question
I am new to Java. I received an error in my project while compiling in Java.
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near
'exit values('1234567','aaa','aaa','aaa','aaa','aaa',0)' at line 1.

exit is a MySQL reserved word and is not allowed as a table name in SQL statements.
Rename the table, or if you really want to use this table name, then put it in backticks:
insert into `exit` values (?,?,?,?,?,?,?)

Refer to this SQL manual
An identifier may be quoted or unquoted. If an identifier contains special characters or is a reserved word, you must quote it whenever you refer to it. (Exception: A reserved word that follows a period in a qualified name must be an identifier, so it need not be quoted.) Reserved words are listed at Section 10.3, “Keywords and Reserved Words”.
This StackOverflow answer exactly addresses your query as to how to use reserved words as an identifier.

Related

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.

Local variable is redundant [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 7 years ago.
Improve this question
I am new to android, can anyone tell me what why is emailresult redundant?
From what I understand is that I retrieve textToUse from another method and name it email here, and then use email to undergo the matcher.find() with the result named emailresult. I then returned emailresult and after that returned the entire email.
I have mess around with it some time, like deleting emailresult and just use email. But then I will still have to create another variable to go under this location:
String emailresult = email.substring(matcher.start(), matcher.end());
It is redundant because you aren't doing anything with emailresult after assigning it a value besides returning it. You can simply do the following without the need to create a variable:
return email.substring(matcher.start(), matcher.end());
There is no need to create a variable
return email.substring(matcher.start(), matcher.end());

Java Oracle Sql statement not performing [closed]

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.

Getting a char(36) UUID from MySQL query [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
What type should I be getting for a char(36) UUID value in a MySQL query?
Query:
ResultSet res = st.executeQuery("SELECT uuid FROM playerdata");
String variable:
String uuid = res.getString("uuid");
The above line is the part I am unsure about. Is a CHAR value a String, an Object, or something else?
Example value:
456f5080-f3b5-11e3-ac10-0800200c9a66
I've tried both strings and objects, but neither seem to work. Just a quick clarification would be greatly appreciated!
Char(36) refers to the datatype of the field in your database. You can store strings up to 36 characters. If you store less than 36 characters, your database will store trailing zeros. In your case, it appears that you are storing UUIDs there, which are 36 character strings.
Since you tagged this as java, you can read this to see what char means in java.
In other contexts, char(36) is a function that will return a dollar sign. The argument of that function has to be an integer and is treated as an ascii code. Sql Server is one such context.
Should be a normal string only.

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