tags:

views:

78

answers:

2

Hi, this is my code but it givas an error would you please help me(in mySQL I have a table that has VARCHAR name ,VARCHAR address and VARCHAR telephone and TINYINT age and BIGINT charge)

I want to insert a name and address and telephone and age with calling this method .but it will give an error for line insertARow("Adam Smit","21 First Avenue, Fairlyland, 87654","123456789",35);
ERROR:create an InsertARow method(String,String,String,Int);

the class:

    insertARow("Adam Smit","21 First Avenue, Fairlyland, 87654","123456789",35);


}

private static void insertARow(String name,String address,String telephone,BigInt age) {

}
+1  A: 

A BIGINT in MySQL is a 64 bit integer type, so you can simply handle it as a long (and/or Long) value in Java, as long as you are using the SIGNED variant.

If you want to support an UNSINGNED BIGINT, then you will have to handle the values as java.math.BigInteger in Java.

Since you don't show any code that actually interfaces with the Database (JDBC) I can't tell you what you're doing wrong.

Joachim Sauer
there is not any difference between long or Long here? also it is unsigned.
Johanna
There's no difference in the data range between `long` and `Long`. Of course there is the difference that one is a primitive type, while the other is a Wrapper class. But that's outside the scope of this question.
Joachim Sauer
would you please help me that how can I send a BigInt age to the sql table (in my code)(I used the type of age as a BigInt!
Johanna
You need to search online for a tutorial on JDBC. Then paste the code that's failing to work along with any stack traces.
Adamski
A: 

Your code is attempting to use BigInt as a Java type, which will not compile. As Joachim mentions you need to use a long or Long in Java.

Adamski