我刚刚开始使用SQL并遇到了问题.
在我的数据库中,我目前有两个表,电影院和剧院.我正在尝试在Cinemas表中创建一个"#The theatre#",用Cinema图表中的Cinema ID(外键)计算Theatres表中的Theatres数量.我让它作为一个SQL查询:
SELECT cinemas.CinemaID,Town,COUNT(*) AS '# of Theatres'
FROM cinemax.cinemas,cinemax.theatres
WHERE cinemas.CinemaID=theatres.CinemaID
GROUP BY cinemas.CinemaID;
Run Code Online (Sandbox Code Playgroud)
但是想知道是否可以在Cinemas表中创建一个列,它自动执行上述查询并将值插入每一行.
它将是一个非常小的数据库,因此速度不是真正的问题,我只想学习如何制作这样的计算列(如果可能的话).
我正在尝试将netbeans连接到我的postgresql数据库.连接似乎有效,因为我只是连接时没有任何错误或异常,getCatalog()等方法也返回正确的答案.
但是当我尝试运行一个简单的SQL语句时,我得到错误"错误:关系"TABLE_NAME"不存在",其中TABLE_NAME是我在数据库中存在的任何一个表.这是我的代码:
Statement stmt = con.createStatement();
ResultSet rs;
String query = "SELECT * FROM clients";
rs = stmt.executeQuery(query);
Run Code Online (Sandbox Code Playgroud)
我在想netbeans可能找不到表,因为它没有查看默认模式(public),有没有办法在java中设置模式?
编辑:我的连接代码.数据库名称是Cinemax,当我省略语句代码时,我没有错误.
String url = "jdbc:postgresql://localhost:5432/Cinemax";
try{
try {
Class.forName("org.postgresql.Driver");
} catch (ClassNotFoundException cnfe) {
System.err.println("Couldn't find driver class:");
cnfe.printStackTrace();
}
Connection con = DriverManager.getConnection( url,"postgres","desertrose147");
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用ASP.NET MVC 4和MongoDB创建一个基本的电影数据库.我的问题出在我的MovieController的POST Update方法中.
[HttpPost]
public ActionResult Update(Movie movie)
{
if (ModelState.IsValid)
{
_movies.Edit(movie);
return RedirectToAction("Index");
}
return View();
}
Run Code Online (Sandbox Code Playgroud)
ModelState包含影片的Id字段(它是ObjectId对象)的错误,并引发以下异常:
{System.InvalidOperationException: The parameter conversion from type 'System.String' to type 'MongoDB.Bson.ObjectId' failed because no type converter can convert between these types
Run Code Online (Sandbox Code Playgroud)
这是更新视图:
@model MVCMovie.Models.Movie
@{
ViewBag.Title = "Update";
}
<h2>Update</h2>
@using (Html.BeginForm())
{
@Html.HiddenFor(m => m.Id);
@Html.EditorForModel()
<p>
<input type="submit" value="Update" />
</p>
}
Run Code Online (Sandbox Code Playgroud)
和模型中的Movie类:
namespace MVCMovie.Models
{
public class Movie
{
[BsonId]
public ObjectId Id { get; set; } …Run Code Online (Sandbox Code Playgroud) 我有一个名为ShippingList的DropDownList,当选择一个值时,我想将该值传递给变量simpleCart.shippingFlatRate.我尝试创建一个var并获取所选值,然后传递该var,但由于某种原因,var shipList保持为null(Firebug控制台).我是asp.net的新手,这是我第一次使用javascript,所以我有点卡住了,这是否是最简单/最简单的传递价值的方式?
<script type="text/javascript">
simpleCart.email = "abc@gmail.com";
simpleCart.currency = "EUR";
simpleCart.cartHeaders = ["Name_noHeader", "Price_noHeader", "increment_noHeader", "Quantity_input_noHeader", "decrement_noHeader_noHeader", "Remove_noHeader", "Total_noHeader"];
var shipList = document.getElementById('<%=ShippingList.ClientID%>');
var shipCost = shipList.options[shipList.selectedIndex].value;
simpleCart.shippingFlatRate = shipCost;
</script>
Run Code Online (Sandbox Code Playgroud)
编辑所有标记:
<%@ Page Title="" Language="C#" MasterPageFile="~/Standardmaster.Master" AutoEventWireup="true" CodeBehind="WebShop.aspx.cs" Inherits="PetShopParadise.Customer_Pages.WebShop" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="mainContent" runat="server">
<script type="text/javascript" src="/simpleCart.js"></script>
<h2>
Welcome to the Web Shop of
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
!</h2>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:PetShopParadiseConnectionString %>"
SelectCommand="SELECT [Name] FROM [Vendors] WHERE ([VendorID] = @VendorID)">
<SelectParameters> …Run Code Online (Sandbox Code Playgroud) 我有一个进度条,并希望使用一个单独的线程填充它,因为主线程在循环中被暂停几秒钟.我正在使用计时器,以便进度条在一定时间内填满.
线程创建:
private void PlayButton_Click(object sender, EventArgs e)
{
progressBar1.Value = 0;
int playTime = getPlayTime();
int progressInterval = playTime / 100;
Thread progressThread = new Thread(barfiller=>fillBar(progressInterval));
progressThread.Start();
//Loops through the collection and plays each note one after the other
foreach (MusicNote music in this.staff.Notes)
{
music.Play(music.Dur);
Thread.Sleep(music.getInterval(music.Dur));
}
progressThread.Abort();
}
Run Code Online (Sandbox Code Playgroud)
按原样,进度条没有任何反应,但是如果我在主线程中调用fillbar(),它就可以工作但是在for循环完成之后填充它,而不是在for循环之前/期间,即使我在之前调用fillbar()环.
线程方法:
private void fillBar(int progressInterval)
{
progressTimer = new System.Windows.Forms.Timer();
progressTimer.Tick += new EventHandler(clockTick);
progressTimer.Interval = progressInterval; //How fast every percentage point of completion needs to be added …Run Code Online (Sandbox Code Playgroud) 我想创建一个Azure应用程序,它执行以下操作:
从我一直阅读的内容来看,似乎有两种方法:Windows Azure Service Bus或使用Queues.每个辅助角色还将结果存储在数据库中.
服务总线似乎更适合其发布/订阅模型,因此所有工作者角色将获得相同的命令并且大致相同的时间.队列似乎更容易使用.
在开发时,服务总线是否可以在本地与仿真器一起使用?我正在使用免费试用版,但在开发过程中无法持续保留应用程序.此外,在使用队列时,如何通知Web角色处理完成?
我似乎忘记了一些最基本的继承规则,因为我无法弄清楚为什么这不起作用.我有一个扩展Node的类SuffixNode.
节点:
class Node
{
public char label;
public Node parent;
public Dictionary<char,Node> children;
public Node(Node NewParent, char NewLabel)
{
this.parent = NewParent;
this.label = NewLabel;
children=new Dictionary<char,Node>();
}
}
Run Code Online (Sandbox Code Playgroud)
SuffixNode:
class SuffixNode: Node
{
public Dictionary<String, int> Location=new Dictionary<String, int>();
public SuffixNode(Node NewParent):base(NewParent, '$')
{
}
public void AddLocation(String loc,int offset)
{
this.Location.Add(loc, offset);
}
}
Run Code Online (Sandbox Code Playgroud)
我试图从SuffixNode类调用主程序中的AddLocation方法,但是它给出了一个错误,说明没有这样的方法(在Node类中):
Node n;
char FirstChar = suffix[0]; //first character of the suffix
if (suffix == "")
{
return true;
}
//If the first …Run Code Online (Sandbox Code Playgroud) 我正在关注此站点的示例,以尝试实现实时Web聊天应用程序.我是javascript的javascript新手,所以我想我只是复制一下这个例子,然后在我添加东西时学习.
这是我正在使用的代码:
@{
ViewBag.Title = "OnlineUsers";
}
<html>
<head>
<title>Online Users</title>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.4/leaflet.css" />
<script src="http://cdn.leafletjs.com/leaflet-0.4/leaflet.js"></script>
</head>
<body>
<div id="wrapper">
<div id="upperPanel">
<div>
<ul id="messages" itemid="@HttpContext.Current.User.Identity.Name">
</ul>
</div>
<div id="friends">
</div>
</div>
<div id="bottomPanel">
<textarea rows="2" cols="100" id="chatMessage"></textarea>
<input id="chatSubmitMessage" type="submit" value="Send" style="margin-left: 10px;" /><br />
</div>
</div>?????????????
<script type="text/javascript">
$(function () {
var pusher = new window.Pusher('0b7eeff567653e170094');
var channel = pusher.subscribe('chat_channel');
channel.bind('message_received', function (data) {
$("#messages").
append('<li>' + data.user + ' ' + data.message + ' …Run Code Online (Sandbox Code Playgroud) c# ×3
javascript ×2
sql ×2
asp.net ×1
asp.net-mvc ×1
azure ×1
database ×1
for-loop ×1
java ×1
jquery ×1
modelstate ×1
mongodb ×1
mysql ×1
postgresql ×1
progress-bar ×1
queue ×1
winforms ×1