Posts

java - jdbc to hive connection refused -

i trying connect hive via jdbc. below code using: import java.sql.drivermanager; import java.sql.resultset; import java.sql.sqlexception; import java.sql.statement; import java.sql.connection; public class hivetojava { private static string drivername = "org.apache.hadoop.hive.jdbc.hivedriver"; /** * @param args * @throws sqlexception */ public static void main(string[] args) throws sqlexception { try { class.forname(drivername); } catch (classnotfoundexception e) { e.printstacktrace(); system.exit(1); } connection con = drivermanager.getconnection( "jdbc:hive://localhost:10000/default", "", ""); statement stmt = con.createstatement(); string tablename = "processed"; resultset res = stmt.executequery("describe " + tablename); while (res.next()) { system.out.println(...

asp.net mvc - MVC layers and DAL & Data layers -

i've been developing multi-tier mvc application , reviewing i've done far. i've gone , done fair bit of reading again on multi-tiers/layers (there heaps of information out there no real consistency or standard), i'm questioning data layer. i suspect have implemented incorrectly (in line design) , may have gone off on tangent. here's i've done: webui includes controllers, view models, views bll includes service classes contain: in-memory manipulation code, e.g. collections... data access code, e.g. ef linq entities. data /models folder contains domain classes /dal folder contains dbcontext classes ... stepping back, , re-reviewing, here see, , i'm questioning: in bll, ef code not correct here. should in data layer. can please confirm? my data layer (i.e. data project) contains context classes, , domain models. i've read people separate data layer a) dal, , b) models. therefore guess dal layer contain context classes ,...

How to send date and time to SQL using java -

i calling stored procedure in database. 2 of parameters requires date , time in sql date format. string x = new simpledateformat("mm-dd-yyyy").format(new date()) + " 00:00:00 am"; string y = new simpledateformat("mm-dd-yyyy").format(new date()) + " 11:59:00 pm"; date fromdate = null; date todate = null; try { fromdate = new simpledateformat("mm-dd-yyyy hh:mm:ss a").parse(x); todate = new simpledateformat("mm-dd-yyyy hh:mm:ss a").parse(y); } catch (parseexception ex) { } callablestatement proc_stmt = con.preparecall("{ call someproc(?,?) }"); proc_stmt.setdate(1, (java.sql.date) fromdate); proc_stmt.setdate(2, (java.sql.date) todate); i believe if send date(excluding time), code works, of no use me database not generate correct results. when run above code classcastexception:java.util.date cannot cast java.sql.date any solution? use java.sql.timestamp class holds date , time sql ...

css - Side navigation submenu flyout pushes down other menu items in IE7 -

Image
this problem showing in ie7. other browsers , ie8 , above work fine. i using sprite map ul side navigation. there fly-out submenu 1 of li elements uses sprite map ul downloading various pdfs. if @ image i've attached, submenu appearing in correct location, it's pushing down below it. (the word "music" should appear directly below word "menu".) i have tried various fixes using display: inline; element , position: static; element, attempts have failed. appreciate on this. website address is: http://www.graysonmain.com/ you use fixed height, height: 58px , display: inline-block li#nav_02 .

sql - Concat 2 column data through another column (group by) -

my table - education state code descr aa 001 aaaaaa aa 002 aaaabbb bb 003 qwerty cc 025 asdfg bb 014 zsedc aa 015 lknhj cc 084 uhygt cc 067 fdrda i want in below format: state code aa 001-aaaaaa,002-aaaabbb,015-lknhj bb 003-qwerty,014-zsedc** cc 025-asdfg,084-uhygt,067-fdrda i trying , succeded in getting column "code" in single row below query: select state, replace(wm_concat(code), ',', ',') code education group state order state; output: state code aa 001,002,015 bb 003,014 cc 025,084,067 and have got respective descr each code through below query: select state, concat(concat(replace(wm_concat(code),',',','), '-'),descr) code education group state,descr order state can me club-up queries desired output. thank in advance. wont ? select state, replace(wm_concat(code||'...

sql - Adding constraints using subquery from other table -

i have 2 tables: messages ( id(pk), sender ) recievers ( id references message(id), reciever, pk(id, reciever) ) here's deal: a message can have 1 sender. done a message can have multiple receivers, receiver cannot receive same message more once. done a sender cannot send message himself. how do part? i tried this: update table recievers add constraint "recievers_ck_self_send" ( reciever not in ( select sender messages message.id=reciever.id)); on oracle database 10g xe, receive following error: sub query not allowed here one work-around can create materialized view containing query identifying "bad rows". create table messages( message_id number not null ,sender_id varchar2(20) not null ,primary key(message_id) ); create table receivers( message_id number not null ,receiver_id varchar2(20) not null ,primary key(message_id,receiver_id) ,foreign key(message_id) referenc...

ios - Calculate the color at a given point on a gradient between two colors? -

Image
so method write (in objective-c/cocoa, using uicolors , i'm interested in underlying math): + (uicolor *)colorbetweencolor:(uicolor *)startcolor andcolor:(uicolor *)endcolor atlocation:(cgfloat)location; so example, have 2 colors, pure red , pure blue. given linear gradient between two, want calculate color that's at, say, 33% mark on gradient: if call method so: uicolor *resultingcolor = [uicolor colorbetweencolor:[uicolor redcolor] andcolor:[uicolor bluecolor] atlocation:0.33f]; i resulting color @ 'b', , similarly, passing 0.0f location return color 'a', , 1.0f return color 'c'. so question is, how go mixing rgb values of 2 colors , determining color @ 'location' between them? you linearly interpolate red, green, , blue channels this: double resultred = color1.red + percent * (color2.red - color1.red); double resultgreen = color1.green + percent * (color2.green - color1.green); double resultblue = color1.blue + per...