My favourite forum rule: We only give homework help to those who show effort
So start doing something...
My favourite forum rule: We only give homework help to those who show effort
So start doing something...
Thank you Peter!
P.S. BTW, your JSP tutorial helped me a lot! :)
It is not 100% bullet-proof solution, but it was intended as kick-off example as we been little tired of continues request "how do I connect JSP to database" or similar. Glad you found it useful.
1. Post num 10 is something what you may want to have look at
2. create empty index.html (*.jsp) with meta tag for redirect in one second that will call upon your servlet. <meta http-equiv="refresh" content="1; url=next_page.html">
Few things for start
MIDlet - MyProject.java
package myProject;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import myProject.screens.LoginScreen;
public class MyProject extends MIDlet{
public String ti;
public String entrydate;
public String result;
private Display display;
public MyProject() {
/* Calendar logincalenda = Calendar.getInstance();
logincalenda.setTime(new Date());
int monthc = logincalenda.get(Calendar.MONTH) + 1;
int datec = logincalenda.get(Calendar.DATE);
int yearc = logincalenda.get(Calendar.YEAR);
String entryDate = "" + yearc + "-" + monthc + "-" + datec;
curdate.setString(entryDate);
int h = logincalenda.get(Calendar.HOUR_OF_DAY);
int m = logincalenda.get(Calendar.MINUTE);
int s = logincalenda.get(Calendar.SECOND);
String thetime = (h < 10 ? "0" : "") + h + "." + (m < 10 ? "0" : "") + m + "." + (s < 10 …
Put your code in ZIP/RAR and upload it with next post so I can have look what is going on. The above is not standard behaviour.
PS: To attach document to post you need to be in Advanced Editing mode (click Go Advanced button bellow editing area) and the when you scroll bellow you will see Manage Attachments. Through this you can attach it
EDIT: wrong answer, sorry
Linked tutorial is 7 years old so if high-end devices used that time are now more likely out of stock and not used any more. Any of current low-end devices can do more then these "high-end".
As for your problem you need to provide better explanation as only thing I understand is you want to provide similar functionality which is easily done with the help of the tutorial.
I have no clue what you saying about multiple MIDlets as there is only one MIDlet that is running requests through HTTP to connect to servlet in order to retrieve data from database.
Closing down this thread as it is getting wrong attention.
If you want forum build from ASP.NET then use Google to search for it
You can write library for text-to-speech either for Java Microedition or Android. (Better check if they released anything for JME there been some hints, but I did not heard anything in regards of it since I did a project that required such library last year and had to fake it with pre-recorded mp3s)
Please keep in mind that hard-coded location of image is absolute to the emulator. You need to adjust it in regards of your phone. Linked example of device browser will help you get correct path with system call if you deploy them....
Sorry I just spotted you are using wrong file location. You cannot provide file location as direct access to you pc system. To get this running from emulator you need to place your image into INSTALATION_WTK_DIRECTORY\appdb\DefaultColorPhone(or what ever phone you choose to use)\filesystem. Here you should find 3 drives c:/, e:/ and root:/ (or c%3A, e%3A and root1)and place image in one of them (c:/ is recommended as that stands for device memory also this image placement can be little try-and-error as I'm using Sony Ericsson WTK where image location is as C:\SonyEricsson\JavaME_SDK_CLDC\WTK2\appdb\SonyEricsson_W810_Emu\filesystem\c%3A\pictures\camera_semc\hdd.png
and in application I used fconn = (FileConnection) Connector.open("file:///c:/pictures/camera_semc/hdd.png");
). Bellow code is working fine on my pc with Sony Ericsson emulator import javax.microedition.midlet.MIDlet; import javax.microedition.lcdui.Display; public class LocalImage extends MIDlet{ private Display display; public LocalImage(){} public void startApp(){ if(display == null){ display = Display.getDisplay(this); } display.setCurrent(new MyForm()); } public void pauseApp(){} public void destroyApp(boolean unconditionl){ } }
import java.io.*;
import javax.microedition.io.*;
import javax.microedition.io.file.IllegalModeException;
import javax.microedition.lcdui.*;
import javax.microedition.io.file.FileConnection;
public class MyForm extends Form {
private Image image;
public MyForm() {
super("Display Image");
FileConnection fconn;
TextField textAfter = null;
try {
fconn = (FileConnection) Connector.open("file:///c:/pictures/camera_semc/hdd.png");///Data/Images/200908/200908A0/25082009004.jpg");
InputStream in = fconn.openInputStream();
image = Image.createImage(in);
in.close();
fconn.close();
}
catch (IOException e1) {
textAfter = new TextField("e1: " + e1.getMessage(), "", 30, TextField.ANY);
}
catch (IllegalModeException e2) {
textAfter = new TextField("e2: " + e2.getMessage(), "", 30, TextField.ANY);
}
catch (java.lang.SecurityException e3) {
textAfter = new TextField("e3: " + e3.getMessage(), "", 30, TextField.ANY);
}
if (image != null) { …
openInputStream can beside IOException throw also IllegalModeException and java.lang.SecurityException you need to catch them too.
Few suggestions on top of this, you should also close InputStream, move form(append) out of try-catch inside simple if/else statement to check if image is not null and based on outcome of this boolean operation you will either add image to form or do nothing
@puneetkay LOL seems you are offended even though the above line came from movie :D, sorry for misunderstanding. Nevertheless if you try to help make sure you do not pick up first resource that pop up on google, which in these cases unfortunately is that terrible site.
@Pmarcoen as you can see the example that you found show only way to access folders (first comment to article) and few replies down the line it does show how you can get document. General idea is:
@puneetkay in traditional street proverb "I gona nail your a$$"linked website is worst case scenario of any tutorials
there is support for loading images from device in-build memory and memory card
All you need to do is use JSR 75 - PDA Optional Packages for the J2ME™ Platform with File Connection API and you there. Here is simple example of device browser that can be used either to extend functionality in order to find and use selected file or simple reuse the principles used in this case (provide path, check file existence and use the file)
Without coding it is difficult advice...
Start using servlets...
Sorry I do no see logic in what you trying to do. Redirect is for giving up current document and moving on next one and not holding on old location.
Will you explain what you are up to?
Not relevant to Java Server Pages, moving to JavaScript
Move that code to servlet, where it actually belong to, and in doing so you will enable yourself for better debugging.
All 3 IDEs that I mentioned are very good. My preference is IntelliJ and I do not like Eclipse (GUI seems to be messy and configurations are over done, too many options equals too many chances to get something wrong). NetBeans is somewhere between these two...
Eclipse, NetBeans, IntelliJ IDEA
Difficult to judge performance. In these days it is more matter of personal preferences.
Welcome to daniweb Jessica.
Please understand this is not 24/7 instance reply service and people reply of their own concern not when somebody demands it.
Make sure that website is not blocked by your firewall at computer. Blocking website from Netgear is likely done in office environment or in case of child protection (instead of making this configuration for each computer on the network)
As in regards of access to your Netgear:
Two options:
A) you pass Displayable object from form to form
B) or have "magic" method changeScreen to do the job as in this MIDlet
package contacts;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.midlet.MIDlet;
import memo.beans.Contact;
public class ContactMIDlet extends MIDlet{
private Display display;
public ContactMIDlet(){}
public void startApp(){
display = Display.getDisplay(this);
changeScreen(CoreUI.MAIN_MENU);
}
public void pauseApp(){}
public void destroyApp(boolean unconditional){}
public void quitApp(){
destroyApp(true);
notifyDestroyed();
}
/**
* Method to simplify movement from screen to screen
* @param _uiClass specifies name of class to be used
* as declared in the CoreUI interface
*/
public void changeScreen(String _uiClass) {
Displayable displayable;
try {
displayable = (Displayable) Class.forName(_uiClass).newInstance();
((CoreUI) displayable).setUIManager(this);
display.setCurrent(displayable);
}
catch (Exception e) {
e.printStackTrace();
}
}
/**
* Overloaded method of changeScreen just pop-up any alerts as need it.
* @param d
*/
public void changeScreen(Displayable d){
display.setCurrent(d);
}
public void changeScreen(String _uiClass, Contact contact) {
Displayable displayable;
try {
displayable = (Displayable) Class.forName(_uiClass).newInstance();
((CoreUI) displayable).setUIManager(this, contact);
display.setCurrent(displayable);
}
catch (Exception e) {
e.printStackTrace();
}
}
}
interface CoreUI
package contacts;
import memo.beans.Memo;
public interface CoreUI {
public final String MAIN_MENU = "contact.gui.MainMenu";
public final String CONTACT_FORM = "contact.gui.ContactForm";
public final String VIEW_CONTACTS = "contact.gui.ViewContacts";
public final String EDIT_CONTACT = "contact.gui.EditContact";
void setUIManager(ContactMIDlet _mgr);
void setUIManager(ContactMIDlet _mgr, Contact contact);
}
where EditContact can look like this for start
public class EditContact extends Form implements CoreUI, CommandListener {
private ContactMIDlet mgr;
private Contact contact;
private Command backCommand, exitCommand, saveCommand;
/**
* Default constructor
*/
public EditContact() { …
>Last year I was in Czech republic ( very close to you?) please enter WWVDNZ in Youtube to see my wonderful travel videos and others so no need for exchange trips have been about there bought the T shirt and returned home where I now try to be serious again
Czech republic is our west neighbour. Nice videos from Prague, but no that is not Slovakia, sorry. Same as saying that New Zealand is Australia, simply doesn't mix.
>you are the type of guy I prefer to talk to as far as this (your)organization is concerned.
Dunno why I'm getting such harsh treatment,as far I'm concerned I haven't been offensive in any way. Personally I do not see daniweb as organization, but as community where people can participated of they own will.
>O yes my Youtube channel is clogz1947 and there are lots of ning links there for your other colleagues who received a very nice website to review and were helpless with the URL given to them.NING learning curve and now I own a Ning network as well see one of the videos for the link it took me 6 weeks to get familiar yeah
Ning is popular and successful network as I mentioned in the other thread and therefore has many videos on internet. As for the "other colleagues, they are just members on this website like me or you. I'm not responsible for their behaviour. If you are not happy with them …
There goes me attempt in flames, no point to repair damage as it is not welcome.
PS: We have sheep in Slovakia too, so I can manage some exchange trip for you. On second though it may not work as I may be busy talking to friends from Amsterdam, Rotterdam and Eidhoven which are great laugh.
Plain text is OK if you looking for management of small amount of data and not necessary structured/organized. For the above task database would be suitable and I would go for serverless/embedded database like JavaDB, HSQLDB or SQLite then MySQL that need server installation as it gives you mobility
I'm sorry if you feel offended by comment, but please understand that we go through hundreds of post daily to ensure that forums goes by desired rules which is not easy task.
PS: Gentlemen if you find some post offending or breaking forum rules please feel free to hit "Flag Bad Post" link next to the post and report it with a short explanation.
Ooops size() was incorrect it should be lenght().
Did you attached ItemStateListener to TextFields?
As I said this
public void itemStateChanged (Item item) {
if (item instanceof TextField) {
String teste = ((TextField)item).getString();
if (teste.size() > 0) {
recordOK = true;
}
}
can be replaced by simple validation method such as
private boolean validation(){
if(name.getString().length() > 0 && telefone.getString().length() > 0){
return true;
}
return false;
}
I am not sure what is wrong or what went wrong .
can you please explain.
clogz14
Hi , welcome to daniweb.
As in regards what Ezzaral meant when he snipped your URLs is that we do not like people posting links to their personal sites. It is far better it you set link in the signature options of Control Panel. Then you can just simply say "please check links in signature for more info". I hope this clarify the issue. If you have some questions you more then welcome to ask
Your validation process is not working. You are listening for changes on TextField, but you actually never associated this listener with textFields (only associated with ChoiceGroup on line 58). Therefore boolean recordOK will never change state from false to true.
You are overcomplicating your life with setting various listeners that you do not need. Simple solution, on save command call validation method that will have boolean return type and there check if user entered any data.
Also
String teste = ((TextField)item).getString();
if (teste != "") {
can be replaced by
String teste = ((TextField)item).getString();
if (teste.size() > 0) {
Make this changes and let me know if you still have any problems with this MIDlet.
If you do so, I'm more then happy to check it out again.
I tried to look at it, but the use of Spanish (I presume it is Spanish and not Italian or Portuguese) make it difficult. Add to it over 300 lines of code where one has no chance to find what is which screen, it is long period of time spend just figuring out what is what. If you can get at least methods names to English, it would be different story
PS: Don't want to hurt your feelings, but boasting about being Java developer and then provide this long code and with none comments says you either lying or you not a good programmer... Nothing personal dude
>that some couple getting married
Agree; marriage is surely a crazy thing! :-)
Are you talking from personal experience? ;)
All the digits in a row, lunchtime today :)
Read somewhere in the news papers that some couple getting married at that time. Crazy :twisted:
Wrong approach. This forum is about you coming here and asking specific questions and not requesting "baby-sitting" service. So please start working and come back with more concrete questions.
Good starting pint would be find out what sort of data you wish to store in database and how should they be organized...
That is what I suspected, but did not want to feel you bad if I ask directly "did you included all libraries and put them in right place?" some people lately take it as rude
PS: You should also have look into servlets and JSTL to minimize use of scriplets in your JSPs
Can you list resources as their are organized on the server like
PROJECT_FOLDER
Here are few suggestions:
1) Your code is growing and becoming more difficult to manage. It is good practice to put each screen in its own class and either pass instance of Display from screen to screen or do something like this article
2) Instead of using arrays create a simple Memo object that can hold "long" type for date&time and string for memo comment. Something like
public class Memo{
private long dateTime;
private String comment;
public Memo(){}
public Memo(long dateTime, String comment){
setDateTime(dateTime);
setComment(comment);
}
public void setDateTime(long dateTime){
this.dateTime = dateTime;
}
public long getDateTime(){
return dateTime;
}
public void setComment(String comment){
this.comment = comment;
}
public String returnComment(){
return comment;
}
}
this become more organized and more efficient then limited size arrays, especially if you decide to store Memo object in vector and pass along for various reasons (reading multiple records from RMS, putting them in Memo objects, storing in vector and passing for further processing)
3)I believe this is school assignment so I will not push you for advanced GUI like CustomItem or Canvas. However I would recommend re-do your application flow. On application start I would show option to "Add Memo" and "View Memos" in form of List. Once add memo selected I would proceed to your current screen with calendar and text area where you will collect data from user and store them.
On other hand view memos should receive either collection of data or query RMS …
As BestJewSinceJC already mention for syntax highlighting you should use code=java
[code=java]System.out.println("Colour Syntax"); [/code] will come as
System.out.println("Colour Syntax");
As for posting errors received from application we leave posting format on you. What is important to as is the use of code tags on posted code (which some people refuse to do and receive pointless infractions and sometimes even ban)
OK, before I start doing anything, would you care to explain what this application is supposed to do?
From what I seen so far I guess you trying to create some sort of memo holder or diary where you will keep a note associated with date and time.
Can you confirm or correct me please?
You will get use-to-it. Main issue with there site is the speed. Members complains about for ages and so far nothing been done
Ouch, looks like I messed up big time without spotting my own mistake
import java.sql.*;
public class OracleConnect {
public static void main(String[] args) throws SQLException {
try {
Class.forName("oracle.jdbc.OracleDriver");
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", "username", "password");
if (conn != null) {
System.out.println("I am Connected to oracle database");
}
conn.close();
}
catch (Exception e) {
System.out.println("ERROR : " + e);
e.printStackTrace(System.out);
}
}
}
C:\TestDB>javac -cp ojdbc14.jar TestDB.java
C:\TestDB>java -cp .;ojdbc14.jar TestDB
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at TestDB.main(TestDB.java:22)
This is getting interesting.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class TestDB {
public static void main(String args[]) {
Connection con = null;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection("jdbc:mysql://128.0.0.1:3306/dbName",
"username", "password");
if(!con.isClosed())
System.out.println("Successfully connected to " +
"MySQL server using TCP/IP...");
} catch(Exception e) {
//System.err.println("Exception: " + e.getMessage());
e.printStackTrace();
} finally {
try {
if(con != null)
con.close();
} catch(SQLException e) {}
}
}
}
While I'm able to run above code, from command line I will receive following stack trace
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at TestDB.main(TestDB.java:22)
PS: Java version 1.6.0_12
plzz somebody help me.i am still stuck at it!!
plzz mods someone help!!
Would be nice if you notified if you tried above recommendations and what happen instead of crying for help.
You can do it through one of the meta tags inside the head block of html document. This will redirect user in 1 sec to next page. So if you leave it empty visitor should hardly notice
<meta http-equiv="refresh" content="1; url=database.jsp" >
and little masking inside web.xml
<servlet>
<servlet-name>Database</servlet-name>
<servlet-class>GetFirstData</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Database</servlet-name>
<url-pattern>/database.jsp</url-pattern>
</servlet-mapping>
replace "GetFirstData" with name of your real servlet and you done
Few things you can try
E:\Coraclexe\app\oracle\product\10.2.0\server\jdbc\lib