# Java program to insert value in Aerospike database is not working

**URL:** <https://discuss.aerospike.com/t/java-program-to-insert-value-in-aerospike-database-is-not-working/2552>\
**Category:** General Discussion\
**Created:** [February 24, 2016, 2:35pm UTC](https://discuss.aerospike.com/t/java-program-to-insert-value-in-aerospike-database-is-not-working/2552 "2016-02-24T14:35:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![raviojha23](https://avatars.discourse-cdn.com/v4/letter/r/3da27b/32.png) [@raviojha23](https://discuss.aerospike.com/u/raviojha23)\
**Post date:** [February 24, 2016, 2:35pm UTC](https://discuss.aerospike.com/t/java-program-to-insert-value-in-aerospike-database-is-not-working/2552/1 "2016-02-24T14:35:51Z")

</div>

I have written a java program to insert an integer and a double in aerospike database. Here is the code snippet

```auto
import java.util.Random;

import com.aerospike.client.AerospikeClient;
import com.aerospike.client.Bin;
import com.aerospike.client.Key;
import com.aerospike.client.policy.WritePolicy;

public class Test{

	public static void main(String[] args){
		try{
			AerospikeClient client = new AerospikeClient("192.168.140.62", 3000);
			
			for(int i=0;i<10000;i++){
				try {
					WritePolicy writePolicy = new WritePolicy();
					Key key = new Key("test" , "myset", "mykey");
					double randomDouble = Math.random();
					Bin bin1 = new Bin("ID",i);
					Bin bin2 = new Bin("Value",randomDouble);
					
					client.put(writePolicy,key,bin1,bin2);
					
				} catch (Exception e) {
					e.printStackTrace();
				}	
			}
			client.close();
			
		}
		catch(Exception e){
			e.printStackTrace();
		}
	}
}

```

The problem is the above code snippet is neither inserting any data nor throwing any errors. Please advise. PS: I am new to aerospike

---

<div class="post-metadata">

**Author:** ![dhanasekaran1980](https://avatars.discourse-cdn.com/v4/letter/d/d78d45/32.png) [@dhanasekaran1980](https://discuss.aerospike.com/u/dhanasekaran1980)\
**Post date:** [February 25, 2016, 11:56am UTC](https://discuss.aerospike.com/t/java-program-to-insert-value-in-aerospike-database-is-not-working/2552/2 "2016-02-25T11:56:33Z")

</div>

Hi,

I am able execute without any modification except the hostname.

Below is the result after execution.

```auto
aql> select * from test.myset where pk='mykey'
+----+---------------------+
| ID | Value |
+----+---------------------+
| 9 | 4589745104084075448 |
+----+---------------------+
1 row in set (0.001 secs)

```

---

<div class="post-metadata">

**Author:** ![raviojha23](https://avatars.discourse-cdn.com/v4/letter/r/3da27b/32.png) [@raviojha23](https://discuss.aerospike.com/u/raviojha23)\
**Post date:** [February 26, 2016, 8:48am UTC](https://discuss.aerospike.com/t/java-program-to-insert-value-in-aerospike-database-is-not-working/2552/3 "2016-02-26T08:48:30Z")

</div>

Yes even I figured that out, I was actually firing a wrong query in aql - my bad. Is there a way to read all the records of a particular set at one go?

---

<div class="post-metadata">

**Author:** ![dhanasekaran1980](https://avatars.discourse-cdn.com/v4/letter/d/d78d45/32.png) [@dhanasekaran1980](https://discuss.aerospike.com/u/dhanasekaran1980)\
**Post date:** [March 5, 2016, 5:49am UTC](https://discuss.aerospike.com/t/java-program-to-insert-value-in-aerospike-database-is-not-working/2552/4 "2016-03-05T05:49:21Z")

</div>

Hi,

Yes, but you need to paginate it. Else you will get timed out.

Thanks, Dhanasekaran
