嗨,我想将值插入到mysql表中.我正在尝试这段代码.我已将值赋给变量,我想将该变量传递给该insert语句.它是否正确?
code
int tspent = "1";
String pid = "trng";
String tid = "2.3.4";
String rid = "tup";
String des = " polish my shoes!";
INSERT INTO `time_entry`(pid,tid,rid,tspend,description) VALUE ('"+pid+"','"+tid+"','"+rid+"',"+tspent+",'"+des+"');
Run Code Online (Sandbox Code Playgroud)
这是我尝试过的,但我无法插入值
try
{
conn=DBMgr.openConnection();
String sqlQuery = "INSERT INTO `time_entry`(pid,tid,rid,tspend,description) VALUE ('"+pid+"','"+tid+"','"+rid+"',"+tspent+",'"+des+"');";
st = conn.createStatement();
rs = st.executeQuery(sqlQuery);
}
Run Code Online (Sandbox Code Playgroud) 嗨,我正在尝试运行此代码,找到div的宽度,这是在另一个div内.但它运行不正常.这该怎么做?
我想要div mitem1的宽度
码:
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
div#mydiv {
width: 100px;
height: 100px;
background-color: red;
}
</style>
<script language="JavaScript">
$('.menubar').each(function(menu){
var len = $(this).find('.mitem').text().length;
alert(len);
});
</script>
</head>
<body>
<div class="menubar">
<table border="1"><tr>
<td><div class="mitem1">Home</div></td>
<td><div class="mitem1">Communities<ul><li>item1</li><li>item2</li><li>item3</li><li>item4</li><li>item5</li></div></td>
<td><div class="mitem1">Project Gallery</div></td>
<td><div class="mitem1">For Our Customer</div></td>
<td><div class="mitem1">Our Services</div></td>
</tr></table>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 嗨,我试图读取topmenu元素中的每个项目的宽度,并添加项目的宽度,并指定为avariable.但是当我运行这段代码时,我正在警告NaN这段代码中的问题是什么:
$(document).ready(function(){
$('.topmenu').each(function(menu){
var btext = $(this).find('.baritem').width();
alert(btext);
var itemswidth = +itemswidth+btext;
alert(itemswidth);
//var width = getTextWidth(btext,"arial","40");
//alert(width);
});
});
Run Code Online (Sandbox Code Playgroud) 我试图通过对象将值插入哈希映射,我想检查是否将值插入到哈希映射中.所以我使用此代码但在运行时我无法获得任何输出.
怎么解决这个?
码:
import java.util.*;
import java.io.*;
import java.lang.*;
public class TaskList
{
private static HashMap<Integer, Object[]> dataz = new HashMap<Integer,Object[]>();
private static HashMap<Integer, Object[]> screen_dataz = new HashMap<Integer,Object[]>();
public final static Object[][] longValues = {{"10", "kstc-proc", "10.10.10.10.10.","5","O"},{"11", "proc-lvk1", "12.1.2.","4","O"},{"13", "trng-lvk1", "4.6.1.","3","O"}};
private static String sl,pid,tid,mval,status;
public static void main(String args[])
{
addTask();
}
public static void addTask()
{
for (int k=0; k<longValues.length; k++)
{
screen_dataz.put(k,longValues);
}
Set mapSet = (Set) screen_dataz.entrySet();
Iterator mapIterator = mapSet.iterator();
while (mapIterator.hasNext())
{
Map.Entry …Run Code Online (Sandbox Code Playgroud) 当我点击提交按钮时,我正在使用此代码将页面的当前网址添加到div中.我没有得到如何调用函数onclick.这该怎么做?
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>localhost</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
$(function () {
var url = $(location).attr('href');
$('#spn_url').html('<strong>' + url + '</strong>');
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="spn_url"></div>
<input type="submit" value="submit" name="submit">
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 您好,我已经编写了这段代码,我在这段代码中尝试的是获取方法的返回值到java swing标签
这是我的代码:
public static int search(java.util.Date date)
{
Connection conn = null;
ResultSet rs = null;
Statement st = null;
int b=0;
try
{
conn=DBMgr.openConnection();
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String dateStr=formatter.format(date);
System.out.println("date"+dateStr);
String sqlQuery = "select sum(time_spend) as Time_Billed_Per_Day,datetime from time_entry where datetime like '"+dateStr+"%' ";
st = conn.createStatement();
rs = st.executeQuery(sqlQuery);
while(rs.next())
{
b = rs.getInt(1);
System.out.println("BILL of the date u specified is:"+b);
}
}
catch(SQLException ex)
{
System.out.println(ex.toString());
}
finally
{
try
{
if(rs!=null)
rs.close();
if(conn!=null) …Run Code Online (Sandbox Code Playgroud) 我正在尝试将css应用于表格内的锚标记.但我无法看到任何变化.这该怎么做?
码:
<!DOCTYPE html>
<html>
<head>
<style>
table.tab>td>a
{
background-color:yellow;
}
</style>
</head>
<body>
<table class="tab">
<tr><td><a href="#">google.com</a></td></tr>
</tr></table>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 嗨,我正在使用此代码来运行shell脚本.我想在运行程序时传递参数"trng-java".就像这样
like java Classname trng-java
Run Code Online (Sandbox Code Playgroud)
码:
import java.io.*;
public class Test
{
public static void main(String[] args)
{
try {
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec(new String[]{"/bin/sh", "/tmp/test.sh", "trng-java"});
BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream()));
String line = "";
while ((line = input.readLine()) != null) {
System.out.println(line);
}
}
catch (Exception e) {
System.out.println(e.toString());
e.printStackTrace();
}
}
}
Run Code Online (Sandbox Code Playgroud)
这该怎么做?
嗨我写了这段代码,接受输入并使用javascript计算2个值.但我无法在第三个输入字段中打印结果.如何做到这一点?
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function updatesum() {
document.form.total.value = (document.form.time.value -0) + (document.form.cost.value -0);
}
</script>
</head>
<body>
<form name="input" action="#" method="get">
Timespent
Timespent:<input type="text" name="time" value=" ">
Cost:<input type="text" name="cost" value=" ">
Totalcost:<input type="text" name="total" value=" ">
<input type="submit" value="Submit" onclick=updatesum()>
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 我正在使用这段代码插入到hashmap中.
我已经分配了多个值Object[],但是当我运行程序时,我收到了这些错误.
我该如何解决这个错误:
<identifier> expected
illegal start of type
';' expected
Run Code Online (Sandbox Code Playgroud)
码:
public final static Object[] longValues = {"10", "iosl-proi", "10.10.10.10.10.","5","O"},{"11", "pree-lee1", "12.1.2.","4","O"},{"13", "trtg-lv1t", "4.6.1.","3","O"};
Run Code Online (Sandbox Code Playgroud) 我正在使用此代码来调用同一类中存在的方法.当我试图调用该方法时,我收到此错误..如何解决此错误
请帮我
错误:
: cannot find symbol
symbol : method getRowCount()
Run Code Online (Sandbox Code Playgroud)
码:
int modelvalue =(int) getRowCount();
System.out.println("This is model"+modelvalue);
Run Code Online (Sandbox Code Playgroud)
方法:
public int getRowCount()
{
return dataz.size();
}
Run Code Online (Sandbox Code Playgroud) 我试图检索并显示此代码中的哈希映射值,但我希望输出是单独的值...我怎么能这样做
码:
import java.util.*;
import java.io.*;
import java.lang.*;
public class TaskList
{
private static HashMap<Integer, Object[]> dataz = new HashMap<Integer,Object[]>();
private static HashMap<Integer, Object[]> screen_dataz = new HashMap<Integer,Object[]>();
public final static Object[][] longValues = {{"10", "kstc-proc", "10.10.","5","O"},{"11", "proc-lvk1", "12.1.2.","4","O"},{"13", "trng-lvk1", "4.6.1.","3","O"}};
private static String sl,pid,tid,mval,status;
public static void main(String args[])
{
addTask();
}
public static void addTask()
{
for (int k=0; k<longValues.length; k++)
{
screen_dataz.put(k,longValues[k]);
}
Set mapSet = (Set) screen_dataz.entrySet();
Iterator mapIterator = mapSet.iterator();
while (mapIterator.hasNext())
{
Map.Entry mapEntry …Run Code Online (Sandbox Code Playgroud)