Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / June 2005

Tip: Looking for answers? Try searching our database.

updateDate error

Thread view: 
M K - 03 Jun 2005 18:06 GMT
1 - Date now = new Date();
2 - uprs.updateDate("LASTMODIFIED", now);

Error i get is "Cannot resolve symbol" on line 2

Any suggestions?
David Harper - 03 Jun 2005 19:33 GMT
> 1 - Date now = new Date();
> 2 - uprs.updateDate("LASTMODIFIED", now);
>
> Error i get is "Cannot resolve symbol" on line 2
>
> Any suggestions?

Yes. Post a larger excerpt of your code if you expect to get a helpful
answer. Possible explanations are that "uprs" is not declared, or that
method "updateDate" is not defined for that object, or that the
declaration of "now" is not within the same scope as the call to
"updateDate".

But without a larger code fragment which puts those two statements into
their wider context, it's all but impossible to say.

Try reading Eric Raymond's "How to ask questions the smart way":

  http://www.catb.org/~esr/faqs/smart-questions.html

and you may begin to understand why your query does not contain enough
information to allow people to help you.

David Harper
Cambridge, England
Lee Fesperman - 04 Jun 2005 17:56 GMT
> > 1 - Date now = new Date();
> > 2 - uprs.updateDate("LASTMODIFIED", now);
[quoted text clipped - 18 lines]
> and you may begin to understand why your query does not contain enough
> information to allow people to help you.

Thanks, David. I tried to wrap my head around his problem but could make no sense of it.
I began to suspect that even the code he posted was mistyped. I gave up, disgusted.

Signature

Lee Fesperman, FFE Software, Inc. (http://www.firstsql.com)
==============================================================
* The Ultimate DBMS is here!
* FirstSQL/J Object/Relational DBMS  (http://www.firstsql.com)

M K - 05 Jun 2005 22:29 GMT
My bad.  there is no problem with uprs only on now

What I am trying to do is put the current date into the LASTMODIFIED field
in an Access db that has been set up as a Date field.

I have a bunch of
   uprs.updateString("DBCOLUMNNAME", txtField.getText());
and they all work fine.  Its just updateDate I can't get to work

Mark

> > > 1 - Date now = new Date();
> > > 2 - uprs.updateDate("LASTMODIFIED", now);
[quoted text clipped - 21 lines]
> Thanks, David. I tried to wrap my head around his problem but could make no sense of it.
> I began to suspect that even the code he posted was mistyped. I gave up, disgusted.
John Currier - 06 Jun 2005 05:50 GMT
You're using the wrong Date class.

java.sql.Date doesn't have a default constructor (which you're calling)
so you're most likely using a java.util.Date.  ResultSet.updateDate()
requires a java.sql.Date.

John
M K - 06 Jun 2005 12:46 GMT
Heres my imports...

import java.sql.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.*;
import java.util.Date;

> You're using the wrong Date class.
>
[quoted text clipped - 3 lines]
>
> John
M K - 06 Jun 2005 14:32 GMT
Heres more code

           conn = DriverManager.getConnection(url);

           stmt = conn.createStatement(
                 ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);

           ResultSet uprs;
           uprs = stmt.executeQuery("SELECT * FROM MAIN");

           uprs.moveToInsertRow();

           Date nowl = new Date();

           uprs.updateString("NAME", txtName.getText());
           uprs.updateString("COMMENT", txtComment.getText());
           uprs.updateString("TYPE", (String)cboType.getSelectedItem());
           uprs.updateDate("LASTMODIFIED", nowl); <--- error with method
updateDate invalid symbol

> You're using the wrong Date class.
>
[quoted text clipped - 3 lines]
>
> John
John Currier - 06 Jun 2005 18:18 GMT
I believe I said that ResultSet.updateDate() requires a java.sql.Date
and not the java.util.Date that you're trying to pass.  Is there a
reason that you're importing java.util.Date?

John
M K - 06 Jun 2005 18:44 GMT
I have been trying all kinds of variety of options.  Do you have a solution?

Again, all I want to do is update the date column with the current date and
time in this format - MM/DD/YY HH:MM:SS

I have the handle to the resultset and was able to set other fields/columns
but am unable to set the date.  If you have another way/suggestion that
could be helpful, please pass it on.  I am fairly new to Java but not to
coding.

Mark

> I believe I said that ResultSet.updateDate() requires a java.sql.Date
> and not the java.util.Date that you're trying to pass.  Is there a
> reason that you're importing java.util.Date?
>
> John
P.Hill - 06 Jun 2005 22:01 GMT
> I have been trying all kinds of variety of options.  Do you have a solution?

Yes, read the posts. John pointed you in the right direction.

> Again, all I want to do is update the date column with the current date and
> time in this format - MM/DD/YY HH:MM:SS

On the Java side of things it does not matter what the format in the
database is, as long as the JDBC driver understands the column to be a DATE.

> I have the handle to the resultset and was able to set other fields/columns
> but am unable to set the date.

I will repeat the comment from John:
>ResultSet.updateDate() requires a java.sql.Date.

See also:
java.util.Date.getTime()
and
java.sql.Date( long date )

But you could let the PreparedStatement do the work and look into:

public void setObject(int parameterIndex, Object x)

"The JDBC specification specifies a standard mapping from Java Object
types to SQL types. The given argument will be converted to the
corresponding SQL type before being sent to the database."

It always works for me, but be careful about Timezones while
you do this.

-Paul


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.