Win a copy of Securing DevOps this week in the Security forum!

Timothy Sam

Ranch Hand
+ Follow
since Sep 18, 2005
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
2
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Timothy Sam

Paweł Baczyński wrote:First, if you need to sort in reverse order, don't use thenComparing(). Use reversed() directly on your original comparator.
Second, if the compiler can not determine the type of s in the lambda you can specify it.

So you'll have
.sorted(Comparator.comparingDouble((Transaction s) -> s.getAmount()).reversed())

It would be even nicer to use a method reference:
.sorted(Comparator.comparingDouble(Transaction::getAmount).reversed())



Hi Paweł,

Perfect! Thank you!
Hi,

I'm trying to sort a List in reverse order. I can do the code below without a problem:



and that works, but when I try to chain with:



It doesn't work and compiler says it could not resolve the method getAmount? What am I missing here?

Thanks in advance!

Here's my full source

My IDE suggests that this can be converted into a Lambda expression.



I only use it like this...



I know that I'm supposed to operate on an Interface, which is function in this case. It's not that I'm being lazy, but could someone please show me how it's done?

Thanks in advance!
That looks super elegant! Thanks! I thought I should always wrap nullables with Optional. Would you have any opinions on that?
Hi,

I'm trying to figure out if there's a more elegant way of doing this with streams rather than checking separately through an if-else statement? How would you rewrite this code? Thanks in advance!

Topic = Multiple subscribers
Queue = One consumer, deletes the messages once sent?

So, say I have 3 consumers in a topic.

1. If only one of them is able to receive the message, is the message queue and waits for the other two consumers to consume it?
2. What happens once all consumers in a topic consumes a message? Is the message deleted?

Thanks!
Hi, I'm trying to collect some questions here in the forums to make a tutorial out for in my blog. I tried to answer your question here in this link.

http://devpinoy.org/blogs/lamia/archive/2010/04/15/the-difference-between-and-equals-when-used-in-strings-for-java.aspx
8 years ago
Thanks Tim H.

From the Sony Ericsson Developer World site, it's funny that they would mention motion gaming support and yet not mention JSR-256 in the list of their supported JSR's and API's.

http://developer.sonyericsson.com/device/loadDevice.do?id=193b15d2-feee-4607-a642-49960c51c345

JSRs & APIs

* CLDC 1.1
* WMA (JSR-120)
* MMAPI(JSR-135)
* Mobile 3D(JSR-184)
* Java Technology for the Wireless Industry(JSR-185)
* File/PIM(JSR-75)
* Mascot Capsule V3
* MIDP 2.0(JSR 118)
* Nokia UI API 1.1


This website mentioned JSR-256 support

http://www.jbenchmark.com/phonedetails.jsp?benchmark=jvm&D=SonyEricsson%20W395&testgroup=null

Mobile Sensor API (JSR-256)

Thanks again.
8 years ago
Hi guys,

Is there an API in Java to take advantage of a phone's motion sensor feature? I want to try especially on Sony Ericsson's W395.

Thanks!
8 years ago
Uhmmm... Help? I tried to GRANT ALL PRIVILEGES ON USERS_TBL TO PUBLIC before running the JUnit tests but still not luck...
Hi Jeanne

Thanks for the reply! Yes, I also run as user "sa"
Hi Ranchers!

I'm currently facing a problem when running a JUnit test within an ANT script. My Unit test calls for an HSQLDB query. Outside of this JUnit test, all my queries like creating a table, insert data to the table and selecting data from the table runs fine. However, when time comes to call my test case class, it throws out a nested exception is java.sql.SQLException: user lacks privilege or object not found: USERS_TBL

I'm running an in-memory database
db.driver=org.hsqldb.jdbcDriver
db.url=jdbc:hsqldb:mem:.
db.user=sa
db.pw=

Below is the stack trace:


[junit] StatementCallback; bad SQL grammar [SELECT user_seq_id, username, pa
ssword FROM users_tbl]; nested exception is java.sql.SQLException: user lacks pr
ivilege or object not found: USERS_TBL
[junit] org.springframework.jdbc.BadSqlGrammarException: StatementCallback;
bad SQL grammar [SELECT user_seq_id, username, password FROM users_tbl]; nested
exception is java.sql.SQLException: user lacks privilege or object not found: US
ERS_TBL
[junit] at org.springframework.jdbc.support.SQLStateSQLExceptionTranslat
or.doTranslate(SQLStateSQLExceptionTranslator.java:98)
[junit] at org.springframework.jdbc.support.AbstractFallbackSQLException
Translator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
[junit] at org.springframework.jdbc.support.AbstractFallbackSQLException
Translator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
[junit] at org.springframework.jdbc.support.AbstractFallbackSQLException
Translator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
[junit] at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTempla
te.java:406)
[junit] at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate
.java:455)
[junit] at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate
.java:463)
[junit] at com.mycompany.dao.spring.UserDAOSpringImpl.findUsers(UserDAO
SpringImpl.java:77)




Below is the Spring JDBC code



Thank you very much and I look forward to your kind answers.
Although... I think there are 3rd party initiatives to allow writing in the Java language then the compiler converts to Objective C code. I don't know if anyone's doing this for commercial purpose right now.
9 years ago
iOS
Hi guys!

I need to know how to configure Velocity properly. I'm using velocity in a batch(CLI) process to send an e-mail and my template file located in a directory somewhere in the file system. I'm using Eclipse and I made sure that the location of my template is included in the classpath (if it is ever needed to do so).

Assuming that my .vm (template) file is located in C:/opt/templates/


I initialize Velocity like this



And load my template like the following



A call to getTemplate throws the error below:

org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource 'my_template.vm'

Is anyone familiar with this? Thanks!