|
that search even me also did.but i didnt get propely how to do with annotations
|
|
|
|
|
|
I have a form in which I have made File no field which hold the Integer value like 1-2-3-4 and so on.
I want that ,when I save a form which has file no 1 ,and then after when I want to save the next record it should remember the last file no and increment by 1.
I have not coded yet anything because I don't know if it is possible?
|
|
|
|
|
chdboy wrote: I don't know if it is possible? It definitely is possible. You just need to use a variable to hold the value, and use that to display in the field. Every time you save a file, increment the value and refresh the displayed field.
Veni, vidi, abiit domum
|
|
|
|
|
thanks for the Idea I'm working on it.
EDIT:
I managed to do what I wanted BUT...
It only happens till the application is open and I'm saving data one after one...as soon as I close to application and opens in again I have see the last file no and enter the next file no manually.
with this code
String filenostr = filenotxtfield.getText();
statement.setString(1,filenostr);
int fileno=Integer.parseInt(filenostr);
fileno++;
String convertno=String.valueOf(fileno);
filenotxtfield.setText(convertno);
statement.executeUpdate();
int rowsAffected = statement.executeUpdate();
if(rowsAffected > 0)
{
JOptionPane.showMessageDialog(null, "Data Inserted successfully!");
}
else
{
JOptionPane.showMessageDialog(null, "Data is not Inserted!", "Not successfully", JOptionPane.ERROR_MESSAGE);
}
statement.close();
con.close();
Addition to that I'm getting error on line
int rowsAffected = statement.executeUpdate();
ERROR:
com.microsoft.sqlserver.jdbc.SQLServerException: Violation of PRIMARY KEY constraint 'PK__Employer__6F09E6800F975522'. Cannot insert duplicate key in object 'dbo.Employer'.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:216)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1515)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:404)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:350)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1715)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:180)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:155)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeUpdate(SQLServerPreparedStatement.java:314)
But as I see in my Management Studio that the data has been saved.but still getting this error ..why?
modified 22-Nov-13 1:08am.
|
|
|
|
|
I'm able to display the value after data is saved, but it is showing me wrong value with this code.
int fileno1=Integer.parseInt(Result.getString(2));
int increment = ++fileno1;
String convertno1=String.valueOf(increment);
filenotxtfield.setText(convertno1);
If 1 and 2 file no already exists after entering 3rd number manually and then save it ,it is showing me 2 not 4.?
|
|
|
|
|
That code looks fine as it stands, but you are not saving the updated count anywhere.
Veni, vidi, abiit domum
|
|
|
|
|
Do I have to save it in the database and then retrieve it?
int increment = ++fileno1;
I have to save increment in the database?
|
|
|
|
|
It depends on how long you need the value, but you have to save it somewhere. If you only need the value for a single execution of the program, then just keep it in memory. If you want to continue where you left off with another separate execution, then you need to kepp it somewhere permanent, database, property etc.
Veni, vidi, abiit domum
|
|
|
|
|
ok right now I have not made is permanent,but I think I will save it in the database so when the application loads it will still remember the last file no ...thanks for the Idea.
Right now I have done it with this code.
int fileno1=Integer.parseInt(Result.getString(2));
int increment = ++fileno1;
int increment2 = ++increment;
filenotxtfield.setText(Integer.toString(increment2));
I have used this code after inserting the data in the database.So now as you suggested I'm working on how to show the next file no upon application starts.
|
|
|
|
|
I'm not sure if you're aware of this. But what this code does is essentially:
int fileno1=Integer.parseInt(Result.getString(2));
fileno1 = fileno1 + 1;
int increment = fileno1;
increment = increment + 1;
int increment2 = increment;
filenotxtfield.setText(Integer.toString(increment2));
if you just want to increment the value of fileno1 (and don't need those variables increment and increment2) by 2:
int fileno1=Integer.parseInt(Result.getString(2));
fileno1 = fileno1 + 2;
filenotxtfield.setText(Integer.toString(fileno1));
|
|
|
|
|
Yes that didn't come to my mind...thank you
|
|
|
|
|
gan gmna ya caranya bikin converter video klo lwat java?
|
|
|
|
|
This is an english website - Please aks your questions in english, or head over to a website serving your language needs.
Veni, vidi, caecus
|
|
|
|
|
Bahasamu sedikit mirip dengan bahasa Indonesia. Dan halaman profile-mu juga berkata bahwa negaramu Indonesia. Lihatlah: sinilah kami bercakap pada dalam Inggris. Belajarlah bahasa Inggris!
Dan mengapa tidak tahu menulis bahasa Indonesia dengan baik? Saya sudah membaca buku-buku dengan ribuan halaman pada dalam bahasa itu, tetapi tidak dapat megerti tanyaanmu.
|
|
|
|
|
Hey,
This will be difficult to explain. I'm not sure if you'll understand. Don't know how to describe it in a good way.
We are 2 developers.
I wrote 2 different WCF's in C# and there are several that will follow. They all share 7 common functions that a user is able to call.
My mate wrote a programm that takes those WCF's.
You can "login" to his program and Choose one of my WCF's via name. And then his program will forward all messages from the chosen WCF to you.
We tried the following:
Create a WebService in Java with those 7 functions and download the WSDL.
Then change the endpoint-URL inside the generated files to the WCF-URL that the user has chosen.
The problem is microsoft.
Microsofts WCF has a unusual WSDL-File.
The same for the .asmx-Webservices.
They are different from the Java - WSDL (Therefore the generated sources are different, too) though the provided functions are the same.
From Java you can consume both asmx and WCF - Services,
but not in a generic way, because when we do it as we do, we get the message that the WSDL at this endpoint is different from the WSDL that we have.
I hope the text was not toooooo confusing.
Does anyone know a solution ?
Greetings,
SheraX
Bildlich:
http://www.upload-pictures.de/bild.php/43100,webserviceSW5Q8.png[^]
|
|
|
|
|
This may be a silly question for Java experts, but even for some one who has some years of Java experience like me, it is still an easily ignored topic. And even the senior developers on our team seem to make mistakes with these.
I want to understand the operators on the Java Integer class. What is Java doing when comparing two Integers? For example, let's say we have Integer a and Integer b. Does Java do reference comparison or value comparison on ==, !=, <, >, <=, >= operators?
And if one of the operator is an Integer and the other is a constant, what does Java do with ==, !=, <, <>, <=, >=?
And if one of the operator is an Integer and the other is an int, what does Java do?
In my experience, seems that Java does reference comparison with two Integers, and seems that it does value comparison with one Integer and one constant.
modified 18-Nov-13 16:13pm.
|
|
|
|
|
The following test program shows what happens:
public class Test {
public static void main(String[] args) {
Integer a;
Integer b;
a = 10;
b = 10;
if (a == b)
System.out.println("True");
}
}
You can also verify by disassembling the class via javap -c .
Veni, vidi, abiit domum
|
|
|
|
|
Richard MacCutchan wrote: The following test program shows what happens:
Errr...I don't think so.
And that is demonstrated by changing the '10' to '1000' and then running the program again.
|
|
|
|
|
You are correct of course; my test was incomplete.
Veni, vidi, abiit domum
|
|
|
|
|
Raptor81 wrote: In my experience, seems that Java does reference comparison with two Integers
Does exactly that for equality and inequality. If it didn't it wouldn't be backwards compatible.
Raptor81 wrote: and seems that it does value comparison with one Integer and one constant.
Yes however the problem with doing that is that one can then forget about equality and inequality. And that becomes even more of a problem because java caches integers in the 0 to 128 range. So simple tests can succeed and then fail in production when bigger values are used. (Keep in mind that the range of integers that are cached is not part of the specification so it can change.)
So the best idea is to never rely on the operators in the first place.
This is demonstrated with the following.
Integer a1 = 1000;
Integer a2 = 1000;
Integer a3 = a1;
Integer b1 = 10;
Integer b2 = 10;
System.out.println("1000 is " + (a1 == a2));
System.out.println("10 is " + (b1 == b2));
System.out.println("1000 != is " + (a1 != a3));
|
|
|
|
|
Integer is not different than any other Java Object
(with the previously noted exception that the jvm provides some help to avoid duplication in the smaller values).
Perhaps one thing that makes it seem confusing is the auto-conversion between 'int' and Integer. I could see that appearing to be confusing at first.
The main thing to remember is that if you want to do numeric comparisons like ==, <, > etc. just make sure you are doing them on 'ints' not Integers.
|
|
|
|
|
Hello everybody.
I am a newbie in Java and I am going to pose a question which may sound silly to most of you , but I run through the whole forum and article list without being able to find a hint.
I have an error in my code which makes me think I do not have, in my classpath, the files needed for my "java.nio.*" import . Figuring my guess is right , how can I know , for any of the packages I import in my project, where the related files are ?
And, which kind of files are they ? for instance , if I am importing the "java.net.*" or "the "java.io.*" packages, are they included in ".jar" files or not ? and where are the related containing files ?
Is there a correspondence rule between the dotted import name form ( package.subpackage1.subpackage2....subpackageN.* ...) and a folder hierarchy somewhere in the filesystem ?
I am using the Netbeans IDE, and I already checked the Tools|Library section, which includes a lot of .jar files, but only for a few of them I've been able to find the related .jar files.
I read a lot of tutorials, manuals ,books and articles about the subject without finding a clear answer to these questions.
Thank you
|
|
|
|
|
tiwal wrote: I have an error in my code which makes me think I do not have, in my classpath, the files needed for my "java.nio.*" import What evidence do you have that leads to this conclusion? The nio package is part of the satndard runtime in rt.jar and should be installed as part of the Java installation.
Veni, vidi, abiit domum
|
|
|
|
|
In effect, actually no evidence at all, Richard, it's just a suspicion I made up by reading some documentation on the net.
But if you say, as I originally thought, that "java.nio.*" is already in the standard runtime, that means my suspicion is wrong.
Anyway, talking in general, is it possible to determine what is (and where is located) the .jar file where a particular import package in contained ?
|
|
|
|