我想访问我的 sql 数据库,而不是放置在ASUS\MSSQLSERVER1数据库名称“Test”中,并使用密码 teste 访问用户 teste
在 Java 代码中,我对此进行了编码:
@Test
public void TesteTemp() throws SQLException, InstantiationException, IllegalAccessException, ClassNotFoundException
{
Class.forName("net.sourceforge.jtds.jdbc.Driver").newInstance();
String connString = "jdbc:jtds:sqlserver://ASUS/Test;instance=MSSQLSERVER1;user=teste;password=teste;";
Connection conn = null;
try{
conn = DriverManager.getConnection(connString);
}catch(SQLException ex){
ex.printStackTrace();
}
conn.close();
}
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
服务器 ASUS 没有名为 MSSQLSERVER1 的实例。
这说得通?
我正在运行 MSSQLSERVER1 服务。
我已经安装了开发工具.我有visual studio 2010和Visual Studio C#Express.安装后启动VStudio,我创建了一个Windows Phone应用程序,运行时说"错误1 Zune软件没有安装.安装最新版本的Zune软件."
我在互联网上看到我必须在工具菜单中连接到模拟器,除了我没有这样的菜单.所以我错过了什么?
SQL Server中是否有一种方法可以从具有日期列(1998到2010)的表中显示会计年度(从10月1日开始到9月30日结束).这是我做的:
select 'FY1999' as FY, site, count(*)
from mytable
where mydate >='10/1/1998'
and mydate <'10/1/1999'
group by site
Run Code Online (Sandbox Code Playgroud)
select 'FY2000' as FY, site, count(*)
from mytable
where mydate >='10/1/1999'
and mydate <'10/1/2000'
group by site
Run Code Online (Sandbox Code Playgroud)
select 'FY2001' as FY, site, count(*)
from mytable
where mydate >='10/1/2000'
and mydate <'10/1/2001'
group by site
Run Code Online (Sandbox Code Playgroud)
这个年度超过10年这样做是不是太重复了?
我有一个大的XML文件,其排列如下:
<item><title>...</title><link>...</link></item>
parse(new InputSource());如果它存储在我的项目目录中,我该如何使用它来指向这个XML文件?我在哪里放置XML文件?
从Spring MVC 3开始,AbstractCommandController不推荐使用,因此您无法再在其中指定命令类setCommandClass().而是在请求处理程序的参数列表中对命令类进行硬编码.例如,
@RequestMapping(method = RequestMethod.POST)
public void show(HttpServletRequest request, @ModelAttribute("employee") Employee employee)
Run Code Online (Sandbox Code Playgroud)
我的问题是我正在开发一个允许用户编辑通用bean的通用页面,因此在运行时之前不知道命令类.如果变量beanClass包含命令类,则AbstractCommandController只需执行以下操作,
setCommandClass(beanClass)
Run Code Online (Sandbox Code Playgroud)
由于我不能将命令对象声明为方法参数,有没有办法让Spring绑定请求参数到请求处理程序主体中的泛型bean?
SQL Server 2005包括"覆盖索引"功能,该功能允许我们选择多个非密钥列包含在现有的非聚簇索引中.
例如,我有以下列:
EmployeeID, DepartmentID, DesignationID, BranchID
Run Code Online (Sandbox Code Playgroud)
以下是两种情况:
EmployeeID是聚簇索引和剩余的列主键(DepartmentID,DesignationID,
BranchID)被作为非聚集索引(复合索引).
EmployeeID是聚簇索引的主键和DepartmentID是与非聚集索引
DesignationID,BranchID属于"包括列"非聚集的索引.
上面两个有什么区别?如果两者都是相同的新引入"覆盖指数"概念?
我有一个测试 DAO 的 junit 4 测试类。
单元测试:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {
"classpath:/WEB-INF/applicationContext-db.xml",
"classpath:/WEB-INF/applicationContext-hibernate.xml",
"classpath:/WEB-INF/applicationContext.xml" })
@TestExecutionListeners({DependencyInjectionTestExecutionListener.class, TransactionalTestExecutionListener.class})
@DataSetLocation("test/java/com/yada/yada/dao/dbunit-general.xml")
@TransactionConfiguration(transactionManager="transactionManager", defaultRollback = true)
@Transactional
public class RealmDAOJU4Test {
@Autowired
private DbUnitInitializer dbUnitInitializer;
@Autowired
private RealmDAO realmDAO;
@BeforeTransaction
public void setupDatabase() {
// use dbUnitInitializer to insert test data
}
@Test
public void testGetById() {
Integer id = 2204;
Realm realm = realmDAO.get(id);
assertEquals(realm.getName().compareToIgnoreCase(
"South Technical Realm"), 0);
assertEquals(8, realm.getRealmRelationships().size());
}
// more test methods annotated here
}
Run Code Online (Sandbox Code Playgroud)
@BeforeTransacation 方法在每个测试方法之前运行。我想做的是:使用我的 DbUnitInitializer 将数据加载到我的数据库中 …
我正在使用 MS 图表控件堆积柱形图类型,我希望 y 轴标签在下午 4 点到晚上 9 点之间以 15 分钟间隔递增。我附上了图表的图像,并附上了生成该图像的示例代码。
<asp:Chart ID="Chart1" runat="server" Height="296px" Width="412px" BackColor="#D3DFF0"
Palette="BrightPastel" BorderDashStyle="Solid" BackGradientStyle="TopBottom"
BorderWidth="2" BorderColor="26, 59, 105">
<Legends>
<asp:Legend TitleFont="Microsoft Sans Serif, 8pt, style=Bold" BackColor="Transparent"
Font="Trebuchet MS, 8.25pt, style=Bold" IsTextAutoFit="False" Enabled="False"
Name="Default">
</asp:Legend>
</Legends>
<BorderSkin SkinStyle="Emboss"></BorderSkin>
<Series>
<asp:Series Name="Series1" ChartType="StackedColumn" BorderColor="180, 26, 59, 105"
Color="220, 65, 140, 240" YValueType="Time" IsValueShownAsLabel="True"
LabelFormat="{0:HH:mm:ss}">
</asp:Series>
<asp:Series Name="Series2" ChartType="StackedColumn" BorderColor="180, 26, 59, 105"
Color="220, 252, 180, 65" YValueType="Time" IsValueShownAsLabel="True"
LabelFormat="{0:HH:mm:ss}">
</asp:Series>
<asp:Series Name="Series3" ChartType="StackedColumn" BorderColor="180, 26, 59, …Run Code Online (Sandbox Code Playgroud) 假设我正在创建一个体育游戏,在这个游戏中,玩家可以玩各种位置,攻击,防御等。所以我从创建一个基类开始:
public abstract class Position
{
public abstract string Name
{
get;
}
}
Run Code Online (Sandbox Code Playgroud)
和子类...
public class Defender : Position
{
public override string Name
{
get { return "Defender"; }
}
}
Run Code Online (Sandbox Code Playgroud)
等等。这一切都很好。
但是现在我需要一个函数来创建这些对象。我需要一个按位置创建的函数。因此,一种可能的解决方案是创建所有位置的枚举并将此值传递给一个函数,该函数打开枚举并返回适当的对象。但这会触发我的代码气味警报。这个灵魂将类、枚举和函数内的开关联系在一起:
public static Position GetByType(Types position)
{
switch(position)
{
case Types.Defender:
return new Defender();
... and further terrible code
Run Code Online (Sandbox Code Playgroud)
我应该考虑什么解决方案?这是哪种设计模式?