Java Queries Here..

ariftwister

Truth Seeker
Hey Guys I am Developing an Android App to Show Local Bus Schedule. And I get a little trouble in executing specific queries.

The Below SQL query Works well in sqlite browser as i want

Code:
SELECT * FROM pnotocdm WHERE time > time('now','localtime') LIMIT 4;
* pnotocdm is the table name
* time is column name
* time('now','localtime') is the function to get current time in local time format.



However when i convert this sql query to Java rawquery() it does not return the result i want. Any help ?

PS- I stored time column values with only hour and minutes.
 
Last edited:
OP
furious_gamer

furious_gamer

Excessive happiness
^^ Try this :

String s = "12:18:00";
DateFormat f1 = new SimpleDateFormat("hh:mm:ss");
Date d = f1.parse(s);
DateFormat f2 = new SimpleDateFormat("h:mma");
f2.format(d).toLowerCase();
 

daljit

Right off the assembly line
i don't know its right place what i want to create a gui to perform various action in windows..like to disable USBstor from reg, create a administrator account, disabling builttin administrator, disabling some services...i want to perform all these with a single click....can anybody help me..thanks in advance and sorry for my comn skill
 
To create GUI in Java you either need to use AWT or Swing. As Swing is derived from AWT and contains much more features, you should use that instead. You can either parametrically create GUI or use NetBeans' quick GUI builder.
 

true_lies

Ambassador of Buzz
Started Android Programming, and was going through a few example codes, and making some of my own.
In this i'm trying to display the analog clock showing the current time with a toggle button.
Getting this error in MainActivity... (marked with #)
Multiple markers at this line
- Syntax error on token ")", ;
expected
- Syntax error on token "(", ;
expected

MainActivity.java
Code:
package com.example.toggleclock;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AnalogClock;
import android.widget.CompoundButton;
import android.widget.ToggleButton;

public class MainActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		final AnalogClock clock = (AnalogClock) findViewById(R.id.AnalogClock);
		ToggleButton toggle = (ToggleButton) findViewById(R.id.ToggleButton);
		
		toggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
		    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
		        
		    	if (isChecked) { 
		        	@Override
#	            public void onClick(View v) {
	                clock.setVisibility(View.VISIBLE);
	            }
		    	}
				else {
					@Override
#	            public void onClick(View v) {
	                clock.setVisibility(View.INVISIBLE);
				}
				}
		    }
		});
	}
}

activity_main.xml
Code:
<RelativeLayout xmlns:android="*schemas.android.com/apk/res/android"
    xmlns:tools="*schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="${packageName}.${activityClass}" >

    <ToggleButton
        android:id="@+id/ToggleButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:textOn="@string/on"
        android:textOff="@string/off"
        android:checked="true" />

    <AnalogClock
        android:id="@+id/AnalogClock"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/ToggleButton"
        android:layout_centerHorizontal="true" />

</RelativeLayout>

Again, pretty much new to Android programming. Let me know if something wrong with the code or any changes.
 

sarita95

Broken In
Which is the best compiler for JAVA? I am currently compiling and running JAVA programs form cmd, but I would like to know which one is the best compiler for JAVA just like we have TurboC and others for C/C++.
 

amit_dhamankar

Right off the assembly line
I have installed the jdk1.8.0_11 I also get the verification that the software is installed successfully. I am using the book "CORE JAVA Volume 1 - Fundamentals" 9th edition written by Cay S. Horstmann, Gary Cornell. In this book they have said to make a directory by using the command "mkdir src". Every thing is fine uptil C:\Program Files\Java\jdk1.8.0_11\bin But after this when I use the command "mkdir src" I get the following error "Access Denied". I have set the path correctly. Please help. I am sorry if I have posted the question in the wrong thread. But I am new to programming. Thank you
 
I have installed the jdk1.8.0_11 I also get the verification that the software is installed successfully. I am using the book "CORE JAVA Volume 1 - Fundamentals" 9th edition written by Cay S. Horstmann, Gary Cornell. In this book they have said to make a directory by using the command "mkdir src". Every thing is fine uptil C:\Program Files\Java\jdk1.8.0_11\bin But after this when I use the command "mkdir src" I get the following error "Access Denied". I have set the path correctly. Please help. I am sorry if I have posted the question in the wrong thread. But I am new to programming. Thank you

This problem is not related to Java, rather to permission settings. You need Admin provilages to modify the files and folders in certain locations like C:\Program Files, C:\Windows, etc. When you ran the command you were most probably in C:\program Files and you were working on a non-elevated command prompt (cmd run without admin privileges) which gave the error on trying to create a new dir there.

I'd recommend creating your Java source files in some other locations like Documents. Or if you necessarily need to create dir in that path then run cmd with admin rights by right clicking on it and choosing "Run as Administrator".
 

tkin

Back to school!!
I have installed the jdk1.8.0_11 I also get the verification that the software is installed successfully. I am using the book "CORE JAVA Volume 1 - Fundamentals" 9th edition written by Cay S. Horstmann, Gary Cornell. In this book they have said to make a directory by using the command "mkdir src". Every thing is fine uptil C:\Program Files\Java\jdk1.8.0_11\bin But after this when I use the command "mkdir src" I get the following error "Access Denied". I have set the path correctly. Please help. I am sorry if I have posted the question in the wrong thread. But I am new to programming. Thank you
Get Eclipse Luna, it takes 5 mins to setup, and then code away, luna supports java 8. Also if you need to learn J2EE, just get TomEE. Coding via notepad is not a a very good way at all, you need to debug your code, see the console, use an IDE.

Also note, if you are new to JAVA altogether please get this book, this is the best book to learn JAVA: SCJP Sun Certified Programmer for Java 6 Study Exam 310-065 Guide (With CD-ROM) (English) 1st Edition - Buy SCJP Sun Certified Programmer for Java 6 Study Exam 310-065 Guide (With CD-ROM) (English) 1st Edition by Sierra, Kathy|Author; Bates, Bert|Aut

- - - Updated - - -

On a side note: Can anyone suggest me some good resources or books to learn Java 8(only new features), specially the lambda functions.
 

vickybat

I am the night...I am...
@Tkin

Hello my friend.:)

I'm a huge fan of cay horstmann. Try this for java 8 - Buy Java SE 8 for the Really Impatient Book Online at Low Prices in India | Java SE 8 for the Really Impatient Reviews & Ratings - Amazon.in

Their Core series act has a very good reference. So i suggest you to try this.

Btw buddy i don't recommend the scjp book by sierra and bates to a newbie into the world of java. I would suggest their head first book to absolute beginners.
 

tkin

Back to school!!
@Tkin

Hello my friend.:)

I'm a huge fan of cay horstmann. Try this for java 8 - Buy Java SE 8 for the Really Impatient Book Online at Low Prices in India | Java SE 8 for the Really Impatient Reviews & Ratings - Amazon.in

Their Core series act has a very good reference. So i suggest you to try this.

Btw buddy i don't recommend the scjp book by sierra and bates to a newbie into the world of java. I would suggest their head first book to absolute beginners.
Thanks, is there any local edition available? The price is out of my range.
 

vickybat

I am the night...I am...
Thanks, is there any local edition available? The price is out of my range.

Yes

Java SE 8 for the Really Impatient (English) 1st Edition - Buy Java SE 8 for the Really Impatient (English) 1st Edition by Horstmann Online at Best Prices in India - Flipkart.com

Even i'm thinking of getting it.
 
There is any site like codecademy for Java ? where I can learn Java interactively doing coding.

- - - Updated - - -

Anybody? [MENTION=47611]furious_gamer[/MENTION] [MENTION=10170]JGuru[/MENTION]
 

RBX

In the zone
^^ Did you checked these?

Link1

Link 2

If these websites allow only the compilation, then I'd like to suggest koding.com
It gives you a VM, and you can install whichever compiler you like, save the code, resume from anywhere. It used to be bad, but when I used it recently, I found it delighting.
 
Top Bottom