|
I did and it works OK. Thanks!
|
|
|
|
|
Needing help in validating textboxes to check if the textbox is null. I am netbeans and doing web application.
Anyone knows where to find tutorial on this?
|
|
|
|
|
Well, there is always the obvious place[^].
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
i am now able to validation textboxes when the textboxes is null a error message will appear.
Right now if the user enter the number 20 and he or she wants to add the number 20 again, an error will occour.
how do i achieve tt?
i tried google however have no clue on how to strt.
Needing help..
|
|
|
|
|
Assuming you've split your code into MVC (Model, View and Controller) - and of course you did so
You will store the data somewhere in a object. For this you're using a set-methode.
This is a typical moment for checking integrity of the value:
public void setIValue(final int iValue){
if(null != iValue && 0 < iValue && 100 > iValue){
this.iValue = iValue;
}
else{
}
}
or you do delegate this validation to another class(when pushing some "OK"-button) or even your textbox itself (write an extension and trigger on lost of focus or keystroke(can become strange if validation takes to long)).
regards,
Torsten
I never finish anyth...
|
|
|
|
|
pancakeleh wrote: i tried google however have no clue on how to strt.
I already gave you a link to the Java tutorials. I suggest you spend some more time going through them, especially the areas that you are having difficulty with.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Hi, i am trying to connect to MySQL database mysql using JAVA .. using code given below,
import java.sql.*;
public class dbExample{
public static void main(String[] args) {
System.out.println("Listing all table name in Database!");
Connection con = null;
String url = "jdbc:mysql://localhost:3306/";
String db = "mydb";
String driver = "com.mysql.jdbc.Driver";
String user = "root";
String pass = "root";
try{
Class.forName(driver);
con = DriverManager.getConnection(url+db, user, pass);
}
catch (Exception e){
e.printStackTrace();
}
}
}
I've picked this example from internet .. and there lot more example i tried using this same driver String driver = "com.mysql.jdbc.Driver"; But this code all other i tried gives me error Driver Class not found ... at this statment Class.forName(driver); ..... and similarly on trying this driver sun.jdbc.odbc.JdbcOdbcDriver the above mentioned statment Class.fonName ... executes but then it gives error on statment con = DriverManager.getConnection(url+db, user, pass); error is No suitable drive found for jdbc:mysql://localhost:3306/mydb
I'm very much confused and tried it toooooo many time in diffrents ways that i could but still unable to create successfull database connection.
I've tried this using notepad / Netbeans both and both on WINDOWS7 and XP ... and both give same error to me ....
Please Please PLease give me any solution .... I shell be very very Thanksfull to you.
|
|
|
|
|
|
Ok Thanks you ver much ....... Problem solved by adding MySQL.jar to Library.
THanks a lot ...
|
|
|
|
|
i have added a delete button on the table that i have created to allow user to delete values straight from the table and the database will then be updated. however when i try to run the program an error incurred.
Error: java.lang.IllegalArgumentException: unrecognized virtual form name: addIncidentStatus
my code as follows:
public String Del_btn_action() {
form1.discardSubmittedValues("addIncidentStatus");
try {
RowKey rk = tableRowGroup1.getRowKey();
if (rk != null) {
incidentStatusDataProvider.removeRow(rk);
incidentStatusDataProvider.commitChanges();
incidentStatusDataProvider.refresh();}
} catch (Exception ex) {
log("ErrorDescription", ex);
error(ex.getMessage());
}
return null;
}
By the way the "addIncidentStatus" is a function in the sessionbean.
May i know what went wrong?
|
|
|
|
|
Hello i have no idea if i should post it at the java forum pr the database forum, pardon me if i post it at the wrong forum. i am currently using netbeans, javadb and glassfish for my project and right now i created a table that allow user to insert values into the database.
The table contains of 2 attributes a ID and Name.
Problem : http://img827.imageshack.us/img827/673/helpnb.png[^][^]
when the user try to add a 24 again as the ID an error page will popup. how do i create a message instead of the error popup?
error popup page : http://img824.imageshack.us/img824/1426/errorye.png[^]
Needing help.
|
|
|
|
|
pancakeleh wrote: how do i create a message instead of the error popup?
Catch the exception[^] and deal with it.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
You need to handle the exception and then display your customize message box as your requirement.
take a look there[^] for getting more details about Exception.
|
|
|
|
|
i have this particular line in my program however when i execute this line it gives me error.
Integer addIncidentID = (Integer) getIncidentidtxt().getValue();
how do i convert from string to integer?
|
|
|
|
|
Of course you can't cast a String to an Integer, they are two completely unrelated types. You have to use the Integer.valueOff(String s) method:
Integer addIncidentID = Integer.valueOff(getIncidentidtxt().getValue());
|
|
|
|
|
// to primitive int i from Integer Object ii
int i = ii.intValue();
// to Integer ii from primitive int i
Integer ii = new Integer( i );
|
|
|
|
|
this is a static method of the type Integer:
int iValue = Integer.parseInt(givenString);
This one throws an exception when converting fails. So best is to wrap in a try/catch:
int iValue=0;
try{
iValue = Integer.parseInt(givenString);
}
catch(NumberFormatException oException){
}
regards,
Torsten
I never finish anyth...
|
|
|
|
|
can i use interger.parseint?
|
|
|
|
|
that's kind of the one I mentioned - if "interger" is just a typo and is supposed to be "Integer".
see post above your post.
regards
Torsten
I never finish anyth...
|
|
|
|
|
Please, check the javadoc !
Yes you can use parseInt but it returns an int, not an Integer. So, depending on your needs, either use valueOf or parseInt.
|
|
|
|
|
pancakeleh wrote:
how do i convert from string to integer?
you can convert string to integer by using various ways
you can use valueOf method of Integer class in this way
Integer obj = Integer.valueOf(str_value);
you can use Integer Constructor
Integer obj = new Integer(str_value);
you can use parseInt method
int objt = Integer.parseInt(str_value);
for more details move there[^]
|
|
|
|
|
For Example:
String abc123 = "123";
Integer abcint = Integer.valueOf(abc123);
|
|
|
|
|
|
int int_page_id=o;
String str_page_id="5";
try {
int_page_id = Integer.parseInt(str_page_id);
} catch(NumberFormatException ex) {
ex.printStackTrace();
}
|
|
|
|
|
String a="2";
int value = Integer.parseInt(a);
|
|
|
|