公告版位
需要找什麼嗎? 左邊分類或許可以幫助你...

package main;

import java.io.IOException;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer;

public class Main {

    public static void main(String[] args) throws Exception {
    HttpServer server = HttpServer.create(new InetSocketAddress(80), 0); // Port

黃彥霖 發表在 痞客邦 留言(0) 人氣()

import javax.swing.*;

JFrame f = new JFrame("標題");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(400, 300);
f.setVisible(true);

Container cp =f.getContentPane();
cp.setLayout(null);

黃彥霖 發表在 痞客邦 留言(0) 人氣()

請先到 Tomcat 網站下載嵌入式 Tomcat 的 JAR  : tomcat-embed-core.jar


package main;

import java.io.File;
import org.apache.catalina.startup.Tomcat;

public class Main {

    public static void main(String[] args) {

        String prjectPath = new File("").getAbsolutePath();
        Tomcat tomcat = new Tomcat();

黃彥霖 發表在 痞客邦 留言(0) 人氣()

select extract(epoch FROM (time0 - time1)) // 取得時間差 (秒數)

select age(now(), timestamp '1989-02-05'); // 取得時間差 (年齡)





黃彥霖 發表在 痞客邦 留言(0) 人氣()

Postgresql JSR 檔要放在 ROOT\WEB-INF\lib 底下 (這裡用 Tomcat)

 

<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.* " %>
<%@ page import="java.io.*" %>
Hello :
<%
try {
    String driver = "org.postgresql.Driver";
    String url = "jdbc:postgresql://localhost:5432/mydb";
    String username = "postgres";

黃彥霖 發表在 痞客邦 留言(0) 人氣()