haskell faktöriyel hesaplama


1 faktoriyel 0 = 1
2 faktoriyel a = a * faktoriyel (a - 1)
3 main = do putStrLn "Hangi Sayının faktöriyeli hesaplanacak ? "
4           say <- readLn
5           print (faktoriyel say)
6

Bookmark and Share
Tags: , ,

Related posts

Yazılım

Comments (0)

Permalink

hibernate jointable kullanımı


import java.io.Serializable;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;

/**
 *
 * @author Muhammed YÜRÜRDURMAZ
 */
@Entity
@Table(name = "KISI_TBL")
public class Kisi implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "KISI_ID")
    private int KisiId;
    @Column(name="ISIM", length=64, nullable=false)
    private String isim;
    @ManyToMany
    @JoinTable(name = "KISI_TELEFON_TBL", joinColumns = {
        @JoinColumn(name = "KISI_ID")},
    inverseJoinColumns = {
        @JoinColumn(name = "TELEFON_ID")})
    private List<Telefon> telefonlar;

    /**
     * @return the KisiId
     */
    public int getKisiId() {
        return KisiId;
    }

    /**
     * @param KisiId the KisiId to set
     */
    public void setKisiId(int KisiId) {
        this.KisiId = KisiId;
    }

    /**
     * @return the isim
     */
    public String getIsim() {
        return isim;
    }

    /**
     * @param isim the isim to set
     */
    public void setIsim(String isim) {
        this.isim = isim;
    }

    /**
     * @return the telefonlar
     */
    public List<Telefon> getTelefonlar() {
        return telefonlar;
    }

    /**
     * @param telefonlar the telefonlar to set
     */
    public void setTelefonlar(List<Telefon> telefonlar) {
        this.telefonlar = telefonlar;
    }
}



import java.io.Serializable;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;

/**
 *
 * @author Muhammed YÜRÜRDURMAZ
 */
@Entity
@Table(name = "TELEFON_TBL")
public class Telefon implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "TELEFO_ID")
    private int telefonId;
    @Column(name = "TELEFON_NO", length = 13, nullable = false)
    private String telefonNo;
    @ManyToMany(mappedBy="telefonlar")
    private List<Kisi> kisiler;

    /**
     * @return the telefonId
     */
    public int getTelefonId() {
        return telefonId;
    }

    /**
     * @param telefonId the telefonId to set
     */
    public void setTelefonId(int telefonId) {
        this.telefonId = telefonId;
    }

    /**
     * @return the telefonNo
     */
    public String getTelefonNo() {
        return telefonNo;
    }

    /**
     * @param telefonNo the telefonNo to set
     */
    public void setTelefonNo(String telefonNo) {
        this.telefonNo = telefonNo;
    }

    /**
     * @return the kisiler
     */
    public List<Kisi> getKisiler() {
        return kisiler;
    }

    /**
     * @param kisiler the kisiler to set
     */
    public void setKisiler(List<Kisi> kisiler) {
        this.kisiler = kisiler;
    }
}

Bookmark and Share
Tags: , , ,

Related posts

Java

Comments (0)

Permalink

hibernate blob kullanarak resim kaydetme


import java.io.Serializable;
import java.sql.Blob;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;

@Entity(name="resim")
public class Resim implements Serializable {
    @Column(name="id")
    @Id
    private int id;
    @Column(name="resim")
    @Lob
    private Blob resim;

    /**
     * @return the id
     */
    public int getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(int id) {
        this.id = id;
    }

    /**
     * @return the resim
     */
    public Blob getResim() {
        return resim;
    }

    /**
     * @param resim the resim to set
     */
    public void setResim(Blob resim) {
        this.resim = resim;
    }

}

Kullanım örneği

Resim r = new Resim();
r.setResim(Hibernate.createBlob(new FileInputStream("resim.jpg")));
s.save(r);
Bookmark and Share
Tags: , , ,

Related posts

Java

Comments (0)

Permalink

java tarih formatlama (SimpleDateFormat)

import java.text.SimpleDateFormat;
import java.util.Date;

public class JavaSimpleDateFormatOrnek{
  public static void main(String args[]){
  Date date = new Date();
  SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
  System.out.println("Bu gün " + sdf.format(date) );
  }
}
Bookmark and Share
Tags: , , , ,

Related posts

Yazılım

Comments (0)

Permalink

jdeveloper 11g ve tuscany

önce tuscany indirin

yeni bir proje oluşturun

tuscany jarlarını projeye ekleyin

interface ve implementation kodları

package com.aaa.testsca002;
import javax.jws.WebService;
@WebService
public interface IMerhabDunya {
public String getResponse(String message);
}
//-------------------
package com.aaa.testsca002;
import javax.jws.WebService;
@WebService
public class MerhabaDunya implements IMerhabDunya {
public MerhabaDunya() {
super();
}
public String getResponse( String message){
return message;
}
}

deneme.composite dosyası

<?xml version="1.0" encoding="UTF-8"?>
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
targetNamespace="http://debish"
name="deneme">
<service name="HelloWorldService" promote="HelloWorldComponent">
<interface.java interface="com.aaa.testsca002.IMerhabDunya" />
<binding.ws />
</service>
<component name="HelloWorldComponent">
<implementation.java  class="com.aaa.testsca002.MerhabaDunya"  />
</component>
</composite>

Ve çalıştırma class ı

package com.aaa.testsca002;
import org.apache.tuscany.sca.host.embedded.SCADomain;
public class DenemeMain {
public DenemeMain() {
super();
}
public final static void main(String[] args) throws Exception {
SCADomain scaDomain = SCADomain.newInstance("deneme.composite");
MerhabaDunya helloworld = scaDomain.getService(MerhabaDunya.class, "HelloWorldComponent");
while(true){
Thread.sleep(1000);
if(false)
break;
}
scaDomain.close();
}
}

project properties > compiler > copy file types to output directory alanına .composite ekle

ve çalıştırma class ını çalıştır.

loglarda servis adresi görünüyor servisi test edebilirsiniz.

Not tuscany 1.5 ile denenmiştir.

Bookmark and Share
Tags: , , , , ,

Related posts

Bilgi Ve Deneyim

Comments (0)

Permalink

php ile base64 kodlamak ve çözmek


<?php
echo base64_encode ( "deneme metni" );
echo "\n";
echo base64_decode ( "ZGVuZW1lIG1ldG5p" );?>

Bookmark and Share
Tags: , ,

Related posts

Uncategorized

Comments (0)

Permalink

php faktöriyel hesaplama

öğrencilere ve yeni öğrenenlere basit bir örnek

<?php
function faktor($i){
if($i != 0) return $i * faktor($i-1);
return 1;
}
echo faktor(5);?>

Denemek için http://codepad.org/EMjpGZ4y

Bookmark and Share
Tags: , ,

Related posts

Uncategorized

Comments (0)

Permalink

Switch to our mobile site