If you just want to know if an object is an instance of or extends a certain class, or implements a certain interface, you can use the instanceof keyword. 

public void myMethod(Object obj) {
    if (obj instanceof String) {
        System.out.println("It's a String");
    }
    else {
        System.out.println("It's not a String");
    }
}

 

https://coderanch.com/t/404450/java/type-object

 

how can I get the type of the object ? (Beginning Java forum at Coderanch)

 

coderanch.com

 

반응형

Message : 'System.Web.HttpUnhandledException' 형식의 예외가 Throw되었습니다.
원격 호스트에서 연결을 닫았습니다. 오류 코드는 0x800703E3입니다.
위치: System.Web.Hosting.IIS7WorkerRequest.RaiseCommunicationError(Int32 result, Boolean throwOnDisconnect)....

This exception indicates that the user closed the connection before the file had finished downloading by closing his/her browser or navigating to another page. Users never see this error but Elmah logs it. You can check your client is connected before writing to down stream but it can not solve the problem completely.

https://stackoverflow.com/questions/22084835/exception-message-the-remote-host-closed-the-connection-the-error-code-is-0x

반응형

테스트 서버 만들어서 사용하려고 AWS FREE TIRE 사용하려다가... 

가입할때 Developer Support가 눌러졌나보다... 나도 모르게 2.8USD가 결제되서..ㅜㅜ 

바로 취소..ㅠㅠ 

https://aws.amazon.com/ko/premiumsupport/knowledge-center/cancel-support-plan/

 

You’ll automatically receive a prorated refund for the remainder of your current month’s support charge to the payment method it was originally charged to, usually within a week.

 

결제한 후에 바로 PLAN을 바꾸면 환불된다는데.. 우선 일주일 기다려 봐야겠다.. 
-----------------------------------------------------늦은 업데이트)역시, 아마존은 메일을 보내면 해결은 좋다! :)취소가 잘되었는지 확인과, 기존과금된 것이 환불 가능한지 물었는데,, 물론 환불해주고, 또 과금될 것이 있으니 그건 크레딧으로 준다고한다. 취소는 당연히 잘 되었고. ..역시 다시한번 아마존 프리티어는 잘 알고 조심히 써야한다... (이번에 MariaDB Test해본다고.. 했다가 $1 또 과금된 건 함정...) 

 

반응형
java.net.UnknownHostException: Unable to resolve host : No address associated with hostname

테스트할 기기에 인터넷 연결 안해두고,, 인터넷 요청을 해버림...ㅍㅎㅎ

외국에선 간혹 wifi bug라고 하긴 하지만..

 

 

Stack Overflow - Where Developers Learn, Share, & Build Careers

Stack Overflow | The World’s Largest Online Community for Developers

stackoverflow.com

 

반응형

'Backend > Java&Spring Framework' 카테고리의 다른 글

[JAVA] instanseof : Object 의 타입알기  (0) 2019.10.13
JAVA8 | lamda  (0) 2016.08.18
spring + mybatis + ppas error message 2  (0) 2015.07.14
spring + mybatis + ppas error message 1  (0) 2015.07.14
ppas  (0) 2015.07.09

# .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener(){ public void onClick(DialogInterface dialog, int which) { result.confirm(); } }).create();

lamda

.setPositiveButton(android.R.string.ok, (dialog, which) -> { result.confirm(); }).create();

반응형

Driver must not be null
  <property name="driver" value="com.edb.Driver" />

Cannot convert value of type [java.lang.String] to required type [java.sql.Driver] for property 'driver': no matching editors or conversion strategy found

<property name="driverClass" value="com.edb.Driver" />

java.lang.IllegalArgumentException: Cannot find class [com.edb.Driver]

 

1. 프로젝트 build path에 로컬경로로 넣어줌.

2. 로컬경로로 인식이 안되는 경우도 있다고 하여 webapp > WEB-INF > spring > lib 폴더 생성 > jdbc파일 추가

3. 프로젝트 build path로 위경로 인식함.

4. 안됨... 톰캣 이것저것만지다가

5. Run configration > classpath > User Entries > Add External JARs > jdbc 파일 추가 하니까 된다!!!!!

와ㅜㅜ이걸로보낸 시간이 얼마여............ㅜㅜ




There is no setter for property named 'seq' in 'class com.restful.test.model.Measure'


* Measure에 변수선언, set, get 등록 안함..

** extends 는 java에서는 변수명이 될 수 없음 (Syntax error on token "extends", invalid VariableDeclarator)

extends_etc로 변수명 선언



There is no setter for property named 'extends' in 'class com.restful.test.model.Measure'


sql.xml

 <result column="extends_etc" property="extends_etc"/>

바꾼 변수명으로 연결시켜줘야함.


====================== 이제 드디어 정상동작!! ===================================


HTTP Status 404 - /test/WEB-INF/views/lists.jsp

controller 에 return 값을 ##@#.jsp 명으로!

return "home";


HTTP Status 500 - An exception occurred processing JSP page /WEB-INF/views/home.jsp at line 24

Property 'values' not found on type com.restful.test.model.Measure


jstl 객체뿌려주는 곳에

        <td>${lists.date}</td> ->      <td>${lists.input_dt}</td>
        <td>${lists.extends}</td> -> <td>${lists.extends_etc}</td>

한번에 좀 바꿔줍시다!


====================== 이제 드디어 정상동작!! ===================================





근데 왜 values가 안나오지..?  

java 대소문자 구문한다... (확실한가... Values -> values 로 변경)


====================== 이제 드디어 정상동작!! ===================================


http://localhost:8080/test/list




반응형

BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext

    <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>${org.springframework-version}</version>
        </dependency>


Injection of autowired dependencies failed
Could not autowire field
@Repository("iMeasureDAO") 잘못선언되어잇었음       


Result Maps collection does not contain value -> Could not find result map com.spring.myapp.book.model.Measure] with root cause
Result Maps collection does not contain value for com.restful.test.model.Measure

    <resultMap  id="AllMemberList" type="com.restful.test.model.Measure"> 
               <result column="seq" property="seq"/>
               <result column="key" property="key"/>
               <result column="contents" property="contents"/>
               <result column="input_dt" property="input_dt"/>
               <result column="extends" property="extends"/>
        </resultMap>
       
        <!-- parameterType="int"  where seq = #{seq} -->
       
        <select id="getMeasureList" resultMap="AllMemberList" >
               select seq, key, values, input_dt, extends
               from measures
        </select>

위에 부분을 지정안해줌
http://hyeonstorage.tistory.com/283



반응형

https://jdbc.postgresql.org/documentation/publicapi/org/postgresql/ds/PGConnectionPoolDataSource.html

property 확인


In any case, in order to use this ConnectionPoolDataSource, you must set the property databaseName. The settings for serverName, portNumber, user, and password are optional. Note: these properties are declared in the superclass.




No bean class specified on bean definition - Spring Forum

http://stackoverflow.com/questions/20544963/java-lang-illegalstateexception-no-bean-class-specified-on-bean-definition



nested exception is java.lang.ClassNotFoundException: com.edb.ds.PGConnectionPoolDataSource




Could not load properties; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/dbpool.properties]



반응형

 



postgreSQL Database Cluster Initialisation Failed... 

문제
계속 이래서 왜그런지 몰랐는데... 
보안때문에 특정 폴더 예)Programs files 같은 폴더에 생성이 안되도록 하는 것이 있단다.. 윈도우 vista 이후에서부터는...
그래서 관리자 권한으로 실행해도 안되고,, 계속 database cluster 만들때 오류가 났던것...

해결
* Data Directory 와 WAL Directory를 c:\Programs Files\ 로 하지말고, 다른 경로에 지정하자! 그럼 해결^.^

참고

http://www.geekscribes.net/blog/2009/04/22/postgresql-database-cluster-initialisation-failed-solution/

반응형

The ResourceConfig instance does not contain any root resource classes.


web.xml 안에 

 <servlet-name>Jersey Web Application</servlet-name>

  <url-pattern>com.pretech/*</url-pattern> 


위에 구조가 package 이름과 맞춰져야 한다. 

반응형

'Backend > Java&Spring Framework' 카테고리의 다른 글

ppas  (0) 2015.07.09
postgreSQL Database Cluster Initialisation Failed....  (0) 2015.07.08
'Building workspace' has encountered an error  (0) 2015.07.01
JSTL c:forEach  (0) 2013.01.25
jsonObject의 해당값 접근하기  (0) 2013.01.23

'Building workspace' has encountered an error"




Errors occurred during the build.

Errors running builder 'Maven Project Builder' on project 'RESTJerseyExample'.

Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.6

Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.6

Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.6

Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.6

반응형





제어판 - 프로그램 및 기능 - Windows 기능 사용/사용 안함 - 인터넷 정보 서비스 - World Wide Web 서비스 - 응용 프로그램 개발 기능 체크



반응형



 

- AMQP(Advanced Message Queue Protocol) + elang으로 구성.

  1. 클라이언트들에서 메시지를 받아서 분배하는 역할

 

* 나의 경우는 웹으로 모니터링 할 수 있게끔 c#으로 client를 구축

1. 홈페이지에서 rabbitmq-dotnet-client-3.3.4-dotnet-3.0.zip 을 받아, RabbitMQ.Client.dll 을 참조하여 RabbitMQ 사용할 준비를 끝낸다.

2. 이 토끼씨는... 예제가 잘 되어 있다. 언어별로... ㅎ 여기를 차근차근 따라하면 okay! (Tutorials : http://www.rabbitmq.com/getstarted.html)

또한, pdf도 제공하고 있으니,, 자세한것은 pdf 참고!! ( 나의 경우는 //2.8. Retrieving messages by subscription used. )

 

3. 기본 알고리즘

var factory = new ConnectionFactory()

{

UserName = "username",

Password = "password",

Protocol = Protocols.FromEnvironment(),

Port = AmqpTcpEndpoint.UseDefaultPort,

//factory.Uri = "amqp://user:pass@hostName:port/vhost";

Uri = "amqp://username:password@uri"

};

 

public class ConnectionFactory

{

public const ushort DefaultChannelMax = 0;

public const int DefaultConnectionTimeout = 30000;

public const uint DefaultFrameMax = 0;

public const ushort DefaultHeartbeat = 0;

public const string DefaultPass = "guest";

public const string DefaultUser = "guest";

public const string DefaultVHost = "/";

 

public AuthMechanismFactory[] AuthMechanisms;

public IDictionary<string, object> ClientProperties;

public static AuthMechanismFactory[] DefaultAuthMechanisms;

public string HostName;

public string Password;

public int Port;

public IProtocol Protocol;

public ushort RequestedChannelMax;

public int RequestedConnectionTimeout;

public uint RequestedFrameMax;

public ushort RequestedHeartbeat;

public ConnectionFactory.ObtainSocket SocketFactory;

public SslOption Ssl;

public string UserName;

public string VirtualHost;

 

public ConnectionFactory();

 

public AmqpTcpEndpoint Endpoint { get; set; }

public string Uri { set; }

public Uri uri { set; }

 

public AuthMechanismFactory AuthMechanismFactory(string[] mechs);

public virtual IConnection CreateConnection();

public virtual IConnection CreateConnection(int maxRedirects);

protected virtual IConnection CreateConnection(int maxRedirects, IDictionary<AmqpTcpEndpoint, int> connectionAttempts, IDictionary<AmqpTcpEndpoint, Exception> connectionErrors, params AmqpTcpEndpoint[] endpoints);

public static TcpClient DefaultSocketFactory(AddressFamily addressFamily);

protected virtual IConnection FollowRedirectChain(int maxRedirects, IDictionary<AmqpTcpEndpoint, int> connectionAttempts, IDictionary<AmqpTcpEndpoint, Exception> connectionErrors, ref AmqpTcpEndpoint[] mostRecentKnownHosts, AmqpTcpEndpoint endpoint);

 

public delegate TcpClient ObtainSocket(AddressFamily addressFamily);

}

 

 

 

IConnection conn = factory.CreateConnection();

 

public interface IConnection : IDisposable

{

bool AutoClose { get; set; }

ushort ChannelMax { get; }

IDictionary<string, object> ClientProperties { get; }

ShutdownEventArgs CloseReason { get; }

AmqpTcpEndpoint Endpoint { get; }

uint FrameMax { get; }

ushort Heartbeat { get; }

bool IsOpen { get; }

AmqpTcpEndpoint[] KnownHosts { get; }

IProtocol Protocol { get; }

IDictionary<string, object> ServerProperties { get; }

IList<ShutdownReportEntry> ShutdownReport { get; }

 

event CallbackExceptionEventHandler CallbackException;

event ConnectionBlockedEventHandler ConnectionBlocked;

event ConnectionShutdownEventHandler ConnectionShutdown;

event ConnectionUnblockedEventHandler ConnectionUnblocked;

 

void Abort();

void Abort(int timeout);

void Abort(ushort reasonCode, string reasonText);

void Abort(ushort reasonCode, string reasonText, int timeout);

void Close();

void Close(int timeout);

void Close(ushort reasonCode, string reasonText);

void Close(ushort reasonCode, string reasonText, int timeout);

IModel CreateModel();

void HandleConnectionBlocked(string reason);

void HandleConnectionUnblocked();

}

 

 

IModel channel = conn.CreateModel();

channel.QueueDeclare(inputQueueName, durable, autoDelete, autoDelete, arguments);

 

 

public interface IModel : IDisposable

{

ShutdownEventArgs CloseReason { get; }

IBasicConsumer DefaultConsumer { get; set; }

bool IsClosed { get; }

bool IsOpen { get; }

ulong NextPublishSeqNo { get; }

 

event BasicAckEventHandler BasicAcks;

event BasicNackEventHandler BasicNacks;

event BasicRecoverOkEventHandler BasicRecoverOk;

event BasicReturnEventHandler BasicReturn;

event CallbackExceptionEventHandler CallbackException;

event FlowControlEventHandler FlowControl;

event ModelShutdownEventHandler ModelShutdown;

 

[AmqpMethodDoNotImplement("")]

void Abort();

[AmqpMethodDoNotImplement("")]

void Abort(ushort replyCode, string replyText);

void BasicAck(ulong deliveryTag, bool multiple);

[AmqpMethodDoNotImplement("")]

void BasicCancel(string consumerTag);

[AmqpMethodDoNotImplement("")]

string BasicConsume(string queue, bool noAck, IBasicConsumer consumer);

[AmqpMethodDoNotImplement("")]

string BasicConsume(string queue, bool noAck, string consumerTag, IBasicConsumer consumer);

[AmqpMethodDoNotImplement("")]

string BasicConsume(string queue, bool noAck, string consumerTag, IDictionary<string, object> arguments, IBasicConsumer consumer);

[AmqpMethodDoNotImplement("")]

string BasicConsume(string queue, bool noAck, string consumerTag, bool noLocal, bool exclusive, IDictionary<string, object> arguments, IBasicConsumer consumer);

[AmqpMethodDoNotImplement("")]

BasicGetResult BasicGet(string queue, bool noAck);

[AmqpUnsupported("RabbitMQ.Client.Framing.v0_8")]

[AmqpUnsupported("RabbitMQ.Client.Framing.v0_9")]

[AmqpUnsupported("RabbitMQ.Client.Framing.v0_8qpid")]

void BasicNack(ulong deliveryTag, bool multiple, bool requeue);

[AmqpMethodDoNotImplement("")]

void BasicPublish(PublicationAddress addr, IBasicProperties basicProperties, byte[] body);

[AmqpMethodDoNotImplement("")]

void BasicPublish(string exchange, string routingKey, IBasicProperties basicProperties, byte[] body);

[AmqpMethodDoNotImplement("")]

void BasicPublish(string exchange, string routingKey, bool mandatory, IBasicProperties basicProperties, byte[] body);

[AmqpMethodDoNotImplement("")]

void BasicPublish(string exchange, string routingKey, bool mandatory, bool immediate, IBasicProperties basicProperties, byte[] body);

void BasicQos(uint prefetchSize, ushort prefetchCount, bool global);

[AmqpMethodDoNotImplement("")]

void BasicRecover(bool requeue);

[AmqpUnsupported("RabbitMQ.Client.Framing.v0_8qpid")]

void BasicRecoverAsync(bool requeue);

void BasicReject(ulong deliveryTag, bool requeue);

[AmqpMethodDoNotImplement("")]

void Close();

[AmqpMethodDoNotImplement("")]

void Close(ushort replyCode, string replyText);

[AmqpUnsupported("RabbitMQ.Client.Framing.v0_8qpid")]

[AmqpUnsupported("RabbitMQ.Client.Framing.v0_9")]

[AmqpUnsupported("RabbitMQ.Client.Framing.v0_8")]

[AmqpMethodDoNotImplement("")]

void ConfirmSelect();

[AmqpContentHeaderFactory("basic")]

IBasicProperties CreateBasicProperties();

[AmqpUnsupported("RabbitMQ.Client.Framing.v0_9_1")]

[AmqpContentHeaderFactory("file")]

IFileProperties CreateFileProperties();

[AmqpContentHeaderFactory("stream")]

[AmqpUnsupported("RabbitMQ.Client.Framing.v0_9_1")]

IStreamProperties CreateStreamProperties();

[AmqpUnsupported("RabbitMQ.Client.Framing.v0_9_1")]

void DtxSelect();

[AmqpUnsupported("RabbitMQ.Client.Framing.v0_9_1")]

void DtxStart(string dtxIdentifier);

[AmqpMethodDoNotImplement("")]

void ExchangeBind(string destination, string source, string routingKey);

[AmqpMethodDoNotImplement("")]

void ExchangeBind(string destination, string source, string routingKey, IDictionary<string, object> arguments);

[AmqpMethodDoNotImplement("")]

void ExchangeDeclare(string exchange, string type);

[AmqpMethodDoNotImplement("")]

void ExchangeDeclare(string exchange, string type, bool durable);

[AmqpMethodDoNotImplement("")]

void ExchangeDeclare(string exchange, string type, bool durable, bool autoDelete, IDictionary<string, object> arguments);

[AmqpMethodDoNotImplement("")]

void ExchangeDeclarePassive(string exchange);

[AmqpMethodDoNotImplement("")]

void ExchangeDelete(string exchange);

[AmqpMethodDoNotImplement("")]

void ExchangeDelete(string exchange, bool ifUnused);

[AmqpMethodDoNotImplement("")]

void ExchangeUnbind(string destination, string source, string routingKey);

[AmqpMethodDoNotImplement("")]

void ExchangeUnbind(string destination, string source, string routingKey, IDictionary<string, object> arguments);

[AmqpMethodDoNotImplement("")]

void QueueBind(string queue, string exchange, string routingKey);

[AmqpMethodDoNotImplement("")]

void QueueBind(string queue, string exchange, string routingKey, IDictionary<string, object> arguments);

[AmqpMethodDoNotImplement("")]

QueueDeclareOk QueueDeclare();

[AmqpMethodDoNotImplement("")]

QueueDeclareOk QueueDeclare(string queue, bool durable, bool exclusive, bool autoDelete, IDictionary<string, object> arguments);

[AmqpMethodDoNotImplement("")]

QueueDeclareOk QueueDeclarePassive(string queue);

[AmqpMethodDoNotImplement("")]

uint QueueDelete(string queue);

[AmqpMethodDoNotImplement("")]

uint QueueDelete(string queue, bool ifUnused, bool ifEmpty);

[AmqpMethodDoNotImplement("")]

uint QueuePurge(string queue);

[AmqpUnsupported("RabbitMQ.Client.Framing.v0_8qpid")]

void QueueUnbind(string queue, string exchange, string routingKey, IDictionary<string, object> arguments);

void TxCommit();

void TxRollback();

void TxSelect();

[AmqpMethodDoNotImplement("")]

[AmqpUnsupported("RabbitMQ.Client.Framing.v0_9")]

[AmqpUnsupported("RabbitMQ.Client.Framing.v0_8qpid")]

[AmqpUnsupported("RabbitMQ.Client.Framing.v0_8")]

bool WaitForConfirms();

[AmqpUnsupported("RabbitMQ.Client.Framing.v0_8qpid")]

[AmqpMethodDoNotImplement("")]

[AmqpUnsupported("RabbitMQ.Client.Framing.v0_8")]

[AmqpUnsupported("RabbitMQ.Client.Framing.v0_9")]

bool WaitForConfirms(TimeSpan timeout, out bool timedOut);

[AmqpUnsupported("RabbitMQ.Client.Framing.v0_8qpid")]

[AmqpMethodDoNotImplement("")]

[AmqpUnsupported("RabbitMQ.Client.Framing.v0_9")]

[AmqpUnsupported("RabbitMQ.Client.Framing.v0_8")]

void WaitForConfirmsOrDie();

[AmqpMethodDoNotImplement("")]

[AmqpUnsupported("RabbitMQ.Client.Framing.v0_9")]

[AmqpUnsupported("RabbitMQ.Client.Framing.v0_8qpid")]

[AmqpUnsupported("RabbitMQ.Client.Framing.v0_8")]

void WaitForConfirmsOrDie(TimeSpan timeout);

}

 

 

 

반응형

 

 

public ActionResult Create()

{

return View();

}

 

public ActionResult Details(int id = 0)

{

Works works = db.Works.Find(id);

if (works == null)

{

return HttpNotFound();

}

return View(works);

}

 

 

유효성 검사

 

이 모든 것이 자동으로 생성된다! 완전 편리해~~~~~ sPRING할 때 유효성검사 다 지정해 줬어야 했는데 여기는 완전 할 필요도 없그만!

 

코드의 Model 개체는 강력한 형식이므로 (IEnumerable<Movie> 개체), 루프문 내부의 item 개체는 Movie 형식입니다. 결과적으로, 다른 여러 가지 장점들과 함께, 컴파일 시점 검사와 코드 편집기 상에서의 완벽한 인텔리센스를 지원 받을 있습니다

반응형

 

  1. 컨트롤러에서 모델 데이터에 접근하기

스캐폴딩(Scaffolding) 기능을 이용하여 새로운 컨트롤러와 뷰를 추가한다.

(CRUD(Create, Read, Update, Delete) 관련된 액션 메서드와 뷰들을 생성해주는 것입니다. (이런 방식으로 자동으로 만들어진 CRUD 액션 메서드와 뷰들을 다른 말로 스캐폴딩(Scaffolding)이라고도 부릅니다)

 

- 컨트롤러 추가

: Controller 폴더 > 우클릭 > Add > Controller

 

DB가 잘 연결될 수 있도록 해당사항에 잘 연결한다.

    

 

 

db에서 key인 것에 키를 등록한다.

 

using System.ComponentModel.DataAnnotations;

 

[Key]

public int SEQ { get; set; }

 

 

그러면 오류생기지 않고 컨트롤러 만들 수 있다!

 

* 전체적 흐름

 

 

기본화면

 

 

 

 

반응형

+ Recent posts