betweenGo

Archive for October, 2009

URLEncoder.encode is Deprecated So What Do I Use for Encoding?

by on Oct.31, 2009, under Java SE

The Surface on Flickr

(Photo: The Surface by Daniel*1977)

URLEncoder.encode(String url) is deprecated.  Java wants you to use URLEncoder.encode(String url, String enc).  But what do you put for the encoding parameter?  I always forget which is the whole point of this post. :-)

URLEncoder.encode(url, "UTF-8");

Also on Windows if you want you can do:

URLEncoder.encode(url, "Cp1252");

For further reading please see default encoding of a jvm.

Share
Leave a Comment : more...

Twitter Weekly Updates for 2009-10-25

by on Oct.25, 2009, under Miscellaneous

  • Seth’s Blog: “What do you need me to do?” Seth says it’s not good to ask that, better instead to describe solutions. http://bit.ly/34q59p #
  • Version Control with Subversion. Undoing changes or rolling back to a previous version. Very simple. http://bit.ly/h0iOD #
Share
Leave a Comment :, more...

How to Alter Table

by on Oct.06, 2009, under Oracle

Rain on a window in Sunnyvale

(Photo: Rain on a window in Sunnyvale by basictheory)

There are various ways to alter a table and I usually forget what they are so I am writing this post to remind me. :-)

Columns

ALTER TABLE foo DROP COLUMN nickname;
ALTER TABLE foo RENAME COLUMN name TO nickname;
ALTER TABLE foo ADD name VARCHAR2(254) DEFAULT 'Frank' NOT NULL;
ALTER TABLE foo ADD age INTEGER DEFAULT 0 NOT NULL;
ALTER TABLE foo MODIFY name VARCHAR2(500);

Constraints

ALTER TABLE foo DROP CONSTRAINT foo_a_f;
ALTER TABLE foo ADD CONSTRAINT foo_b_f FOREIGN KEY (bar_id) REFERENCES bar (id);

If you forget the name of a constraint and you can try to find it using this handy piece of SQL.

SELECT constraint_name FROM user_constraints WHERE constraint_name LIKE 'foo_%_f%';
Share
Leave a Comment : more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!