|
chdboy wrote: The row count is 0 when I debug it....but I'm using the same username and password what's in the database,why is it not accepting it? I have no idea since I have no access to your system. You need to investigate further to discover what is happening.
Use the best guess
|
|
|
|
|
Now I have changed the code
PreparedStatement preparedStatement = Connectionstring().prepareStatement(
"Select Username from dbo.LoginDetails where Username = ? and Password =?");
String User = tf_Fname.getText();
String _Pass = new String(tf_Lname.getPassword());
preparedStatement.setString(1, User);
preparedStatement.setString(2, _Pass);
ResultSet resultSet = preparedStatement.executeQuery();
while (resultSet.next())
{
System.out.println("Username is "+ resultSet.getString(1)+"Password is "+resultSet.getString(2));
}
But now it's picking up the right Username from the table ,if I don't use
+"Password is "+resultSet.getString(2) in the Print line,and if I use that I get an error
com.microsoft.sqlserver.jdbc.SQLServerException: The index 2 is out of range.
|
|
|
|
|
I guess that you need to look more closely at the contents of your ResultSet and its individual property items. Check with your debugger and also the documentation for the classes that you are working with.
Use the best guess
|
|
|
|
|
I think I got what is wrong with it.....I'm missing Select Username,Password ...hehe thanks
|
|
|
|
|
So the code is telling you the values are not equal.
Figure out what the values are and you will see the difference. Either a debugger or a print them out.
But as a guess there is a case difference. The query doesn't care but the comparison does.
|
|
|
|
|
com.microsoft.sqlserver.jdbc.SQLServerException: The result set has no current row.
But when I see it in the Database there are plenty of rows.
I don't understand why it is not picking up the rows ?
|
|
|
|
|
How would one mutate an object that is final? By referencing the object and then doing a mutate() operation on it? e.g.:
final Object o = new Object();
o.mutate();
I don't understand. If it was declared final, then how come you are allowed to mutate it (or is that not true)?
How would one make the Object immutable then? Meaning: not mutable in any way, not even by reference.
How do I make sure a reference cannot modify the object it refers to? So that MyObject o = new Object(); o.modify(); is not possible?
I also read on Wikipedia the following example:
final Position pos = new Position();
members:
pos.x, pos.y, pos.z are mutable still, unless they are declared final.
So if I am understanding this correctly, in order to make an object/class completely immutable, everything in it including its reference has to be declared final? e.g.:
final Position pos = new Position();
class Position {
final int x;
final int y;
final int z;
public Position(){
x=1;
y=2;
z=3;
}
final void doA(){}
final void doB(){}
}
|
|
|
|
|
|
Referring to that article, Listing 1: Q.: "Because Date is mutable, the scheduleTask method must be careful to defensively copy the date parameter (perhaps through clone()) into its internal data structure. Otherwise, task1 and task2 might both execute tomorrow, which is not what was desired. Worse, the internal data structure used by the task scheduler could become corrupt."
A few questions on this:
1) What is 'copying defensively'?
2) What do they mean by 'internal data structure'?
3) How could task1 and task2 execute tomorrow if the code is to be executed today? Then how can new Date() be tomorrow? I don't understand.
4) How would the internal data structure become 'corrupt'? What is 'corrupt' in this context? Containing inconsistent values?
|
|
|
|
|
These questions should be addressed to the writer of that white paper.
Use the best guess
|
|
|
|
|
Hi,
Iam looking for complete example using Spring to get connection pool object(datasource) which is created in websphere server.
I have tried in many ways but no luck facing with different kind of errors.
Thanks in advance for your time.
|
|
|
|
|
Greetings all.
I have a program calculation ip address like this.
public static void main(String[]args){
int host=450;
String sMask="255.255.254.0";
String[] octet;
String IpAddress="192.168.100.0";
octet = IpAddress.split("\\.");
int oct1=Integer.parseInt(octet[0]);
int oct2=Integer.parseInt(octet[1]);
int oct3=Integer.parseInt(octet[2]);
int oct4=Integer.parseInt(octet[3]);
int i;
System.out.println("Ip Address \t \tSubnet Mask");
for(i=oct4;i<host;i++){
System.out.println(oct1+"."+oct2+"."+oct3+"."+i+"\t \t"+sMask);
}
}
print out from this program
Ip Address Subnet Mask
192.168.100.0 255.255.254
192.168.100.1 255.255.254
192.168.100.2 255.255.254
192.168.100.3 255.255.254
until...
192.168.100.449 255.255.254
I want this program,if ip address octet 4 value "192.168.100.255",then continuing this program,like this.
next >
192.168.101.0 255.255.254
192.168.101.1 255.255.254
192.168.101.2 255.255.254
until ...
192.168.101.193 and Finish.
What the lack from my program?
|
|
|
|
|
You need to add some extra code to cater for when i gets above 255. Something like:
for(i=oct4;i<host;i++){
int value = i / 256;
int rem = i % 256;
oct3 += value;
System.out.println(oct1 + "." + oct2 + "." + oct3 + "." + rem + "\t \t" + sMask);
}
Use the best guess
|
|
|
|
|
The code above increments both oct3 and oct4 at the same time, one ahead the other, respectively.
Change:
oct3 += value; to:
oct3 = value; for:
for(i=oct4;i<host;i++){
int value = i / 256;
int rem = i % 256;
oct3 = value;
System.out.println(oct1 + "." + oct2 + "." + oct3 + "." + rem + "\t \t" + sMask);
}
|
|
|
|
|
Actually we were both wrong; it should be:
value += oct3;
System.out.println(oct1 + "." + oct2 + "." + value + "." + rem + "\t \t" + sMask);
Use the best guess
|
|
|
|
|
good call.
|
|
|
|
|
Hi,
We have a requirement to capture a signature on the tablet in 3 byte ASCII format and then base64 encoding on it. Maximum characters allowed is 1024 only.The requirement is for browser based thin client
Thanks
|
|
|
|
|
when i run my web project with tomcat(stat as a NT service),if the service start with system users ,the project won't run properly,
however,when the service log on with administrator(current user),the project run successfully.why ?
|
|
|
|
|
Because the local system account has different permissions and environment than the user.
There are many possible reasons why it might fail.
And if you check your resources before using and log errors it would probably tell you exactly what those are.
|
|
|
|
|
I have checked the tomcat log, and the problem has been solved .
thank you~ ^-^
|
|
|
|
|
Hi!! I'm trying to understand the sharpen your pencil Class Puzzle4 from head first java.. But the math and the logic is confusing me... I hope someone can give me some explanation before I move on in the book... The output of the code should be Result 543345
public class Puzzle4 {
public static void main (String[] args){
Puzzle4b[] obs = new Puzzle4b[6];
int y = 1;
int x = 0;
int result = 0;
while (x < 6){
obs[x] = new Puzzle4b();
obs[x].ivar = y;
System.out.println("obs[x] = " + obs[x].ivar);
y = y * 10;
System.out.println(" Y = " + y);
x = x + 1;
System.out.println(" x = " + x);
}
x = 6;
System.out.println(" x = " + x);
while (x > 0){
x = x - 1;
System.out.println(" x = " + x);
System.out.println("obs[x].doStuff(x) = " + obs[x].doStuff(x));
result = result + obs[x].doStuff(x);
}
System.out.println("Result " + result);
}
}
class Puzzle4b {
int ivar;
public int doStuff(int factor){
if (ivar > 100){
System.out.println("ivar = " + ivar);
return ivar * factor;
}
else{
return ivar * ( 5 - factor );
}
}
}
What isreturn ivar * ( 5 - factor );????
ivar is an instance and the value of it is unique to every object is that right?? The logic of the method is confusing me. I understand that x is the argument to
modified 15-Jul-13 17:27pm.
|
|
|
|
|
ivar is an integer variable whose value is set for every new instance of the Puzzle4b class. However, without a lot more information it's anyone's guess what its purpose is or what this project is about. I suggest you go back to wherever you found this code and ask the person who wrote it.
Use the best guess
|
|
|
|
|
obs[5]= 100000>100 true. 100000*5= 500000
obs[4]= 10000 >100 True. 10000*4= 40000
obs[3]= 1000 > 100 true. 1000*3= 3000
obs[2]= 100>100 False. 100*(5-2)= 300
obs[1]= 10>100 False. 10*(5-1)= 40
obs[0]= 1>100 False. 1*5= 5
Add them all up you get 543345
|
|
|
|
|
Fascinating! And what is that supposed to mean?
Use the best guess
|
|
|
|
|
Did you really read the code dude?
The output is 543345 observe that the object obs[x] is an array that means obs[x]= {1,10,100,1000,10000,100000}
obs[5]= 100000>100 true. 100000*5= 500000
obs[4]= 10000 >100 True. 10000*4= 40000
obs[3]= 1000 > 100 true. 1000*3= 3000
obs[2]= 100>100 False. 100*(5-2)= 300
obs[1]= 10>100 False. 10*(5-1)= 40
obs[0]= 1>100 False. 1*5= 5
add them and you will get the 543345.. I understand the logic now how come you still don't and you were trying to help me?
|
|
|
|