我正在使用PostgreSql版本:
postgres=# select version();
version
-------------------------------------------------------------
PostgreSQL 9.2.4, compiled by Visual C++ build 1600, 64-bit
(1 row)
Run Code Online (Sandbox Code Playgroud)
我从连接到数据库postgres=#
来newdb=#
....现在我在newdb=#
数据库中,我想拔掉,然后返回到postgres=#
数据库....
这该怎么做 ?
我试过了 disconnect newdb;
但它给了erroe ::
postgres=# create database newdb;
CREATE DATABASE
postgres=# \c newdb;
WARNING: Console code page (437) differs from Windows code page (1252)
8-bit characters might not work correctly. See psql reference
page "Notes for Windows users" for details.
You are now connected to database "newdb" as user "postgres".
newdb=# …
Run Code Online (Sandbox Code Playgroud) CREATE TABLE app_for_leave
(
sno integer NOT NULL,
eid integer,
ename varchar(20),
sd date,
ed date,
sid integer,
status boolean DEFAULT false,
CONSTRAINT pk_snoa PRIMARY KEY (sno)
);
Run Code Online (Sandbox Code Playgroud)
基本插入是::
INSERT INTO app_for_leave(sno, eid, sd, ed, sid, status)
VALUES(1,101,'2013-04-04','2013-04-04',2,'f' );
Run Code Online (Sandbox Code Playgroud)
...
INSERT INTO app_for_leave(sno, eid, sd, ed, sid, status) VALUES (?, ?, ?, ?, ?, ?);
Run Code Online (Sandbox Code Playgroud)
我的要求::如何使用存储过程将数据插入表中?
import java.util.Scanner;
class MyClass
{
public static void main(String args[])
{
Scanner scanner = new Scanner(System.in);
int employeeId, supervisorId;
String name;
System.out.println("Enter employee ID:");
employeeId = scanner.nextInt();
System.out.println("Enter employee name:");
name = scanner.next();
System.out.println("Enter supervisor ID:");
supervisorId = scanner.nextInt();
}
}
Run Code Online (Sandbox Code Playgroud)
我在尝试输入名字和姓氏时遇到了这个异常.
Enter employee ID:
101
Enter employee name:
firstname lastname
Enter supervisor ID:
Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(Unknown Source)
at java.util.Scanner.next(Unknown Source)
at java.util.Scanner.nextInt(Unknown Source)
at java.util.Scanner.nextInt(Unknown Source)
at com.controller.Menu.<init>(Menu.java:61)
at com.tests.Employeetest.main(Employeetest.java:17)
Run Code Online (Sandbox Code Playgroud)
但如果我只输入名字,它的工作.
Enter employee ID:
105 …
Run Code Online (Sandbox Code Playgroud) 如何反序化这种奇怪的XML.在我看来,道具实体缺失(在prop-s周围),但我不能改变这个xml(web服务)的来源.
<parents>
<parent?name="first">
<description><![CDATA[Description for the first-Entity]]></description>
<prop name="level">
<value><![CDATA[1]]></value>
</prop>
<prop name="enabled">
<value><![CDATA[true]]></value>
</prop>
<prop name="version">
<value><![CDATA[1.0-beta3]]></value>
</prop>
</parent>
<parent?name="second">...</parent>
...
</parents>
Run Code Online (Sandbox Code Playgroud)
我的实体是
public class Test?{
@Test
public void deserializerTest() throws JsonParseException, JsonMappingException, IOException {
ObjectMapper om = new XmlMapper();
List<Parent> xml = om.readValue(new File("./test.xml"),
new TypeReference<List<Parent>>() {});
}
}
public class Prop {
@JacksonXmlProperty(isAttribute = true)
public String name;
@JacksonXmlText
public String value;
}
@JacksonXmlRootElement
public class Parent {
@JacksonXmlProperty(isAttribute = true)
public String name;
public String description; …
Run Code Online (Sandbox Code Playgroud) 有没有办法获取加载的页面的URL?
我想要加载的页面的URL,在我的控制器中我将在init()方法中调用方法getUrlOfPage().
我需要URL源将其用作输出中的上下文的输入.
如何获取页面的URL?
我想以$12,050,999.00
格式显示金额.
我尝试如下:
<h:outputText value="#{sampleBean.Amount}">
<f:convertNumber pattern="###,###" currencySymbol="$" type="currency"/>
</h:outputText>
Run Code Online (Sandbox Code Playgroud)
但是,它没有以所需格式显示数量.我得到了12,050,999
.
所需格式如下图所示:
我怎样才能做到这一点?
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Growing Circles</title>
</head>
<body>
<canvas id="c" width="960" height="720"></canvas>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
JavaScript的
var canvas = document.getElementById( "c" ),
ctx = canvas.getContext( "2d" );
ctx.lineWidth = 3;
ctx.beginPath();
ctx.arc( 500, 350, 60, 0, 2 * Math.PI, false );
ctx.fillStyle = "#4DA54D";
ctx.fill();
ctx.strokeStyle = "DarkRed";
ctx.stroke();
ctx.beginPath();
ctx.arc( 500, 350, 120, 0, 2 * Math.PI, false );
ctx.strokeStyle = "OliveDrab";
ctx.stroke();
ctx.beginPath();
ctx.arc( 500, 350, 180, 0, 2 * Math.PI, false );
ctx.strokeStyle = "#530053"; …
Run Code Online (Sandbox Code Playgroud) 我在用 "PostgreSQL 9.3.5"
我有一个带有列的Table(StackOverflowTable
). (SoId,SoName,SoDob)
我希望有一个Sequence generator
列SoId
是一个字母数字值.
我想在postgresql中自动增加一个字母数字值.
For eg : SO10001, SO10002, SO10003.....SO99999.
Run Code Online (Sandbox Code Playgroud)
编辑:
如果明天我需要生成一个可以作为SO1000E100, SO1000E101,...
并具有良好性能的序列.那么什么是最好的解决方案!
我是使用POSTMAN的新宠 - Rest Client - Chrome API
我想使用Basic Auth
POSTMAN中提供的内容.
我正在尝试登录我的Google帐户url
- " https://www.gmail.com ".
我提供了我Username & Password
的Basic Auth
,我曾尝试过GET and POST
.
我有一个Status 200 OK
加载我home page
但它没有登录.
我知道我需要更改网址,但我无法找到正确使用的网址?
如果为不同类型的Auth提供了@examples也会有所帮助.
DDL
命令如下:
CREATE TABLE
- 使用用户提供的列名创建一个表.
DROP TABLE
- 删除所有行并从数据库中删除表定义.
ALTER TABLE
- 从表中添加或删除列.
如果有可能在PostgreSQL和Java中使用这些命令,我需要几个例子吗?
public boolean create(Employee employee) {
try {
callableStatement = openConnection().prepareCall("{call insert_employee(?,?,?)}");
callableStatement.setInt(1, employee.getEid());
callableStatement.setString(2, employee.getEname());
callableStatement.setInt(3, employee.getSid());
i = callableStatement.execute();
callableStatement.close();
closeConnection();
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return i;
}
Run Code Online (Sandbox Code Playgroud)
有没有机会在这种类型中使用DDL CREATE命令?用准备好的陈述?