parameterized

parameterized sql query - asp.net / c#

浪子不回头ぞ 提交于 2019-11-29 14:19:48
So I recently learned that I should absolutely be using parametrized query's to avoid security issues such as SQL injection. That's all fine and all, I got it working. This code shows some of the code how I do it: param1 = new SqlParameter(); param1.ParameterName = "@username"; param1.Value = username.Text; cmd = new SqlCommand(str, sqlConn); cmd.Parameters.Add(param1); //and so on But the problem is, I have over 14 variables that needs to be saved to the db, it's like a registration form. And it would look really messy if I have to write those lines 14 times to parametrize each variable. Is

Prevention against SQL Injection in Hibernate

假如想象 提交于 2019-11-29 13:24:25
I have used hibernate to interact with my database, now I wanted to make my database layer secure against SQL Injection, so I did some research and I found out that my queries should be parameterized , so does it mean if I just structure my HQL queries as: List mothers = session.createQuery( "select mother from Cat as cat join cat.mother as mother where cat.name = ?") .setString(0, name) .list(); Then it's parameterized and protected from SQL Injection, or is there something else which I need to do... One other thing was mentioned - " Always escape your Data " How can that be achieved ??

Pass reference of object to a new Thread

主宰稳场 提交于 2019-11-29 12:01:19
I have an object that contains a very large 3D-array of doubles and I need to start a new thread that need the data of this array, so I will either need to start a new thread passing the object (which contains a whole lot of other data too) to the new thread or I just pass the 3D-array to the new thread. For the first solution I would simply do the following: MyClass { ... public double[,,] _data = new double[x,y,z]; ... } MyMethod(object MyObject) { //do stuff with (MyObject as MyClass) } MyClass _newObject = new MyClass(); Thread thread = new Thread(new ParameterizedThreadStart(MyMethod));

Junit Parameterized tests together with Powermock - how?

那年仲夏 提交于 2019-11-29 04:35:34
问题 I've been trying to figure out how to run parameterized tests in Junit4 together with PowerMock. The problem is that to use PowerMock you need to decorate your test class with @RunWith(PowerMockRunner.class) and to use parameterized tests you have to decorate with @RunWith(Parameterized.class) From what I can see they seem mutually excluded!? Is this true? Is there any way around this? I've tried to create a parameterized class within a class running with PowerMock; something like this:

Retrieve build number or artifacts of downstream build in Jenkins

流过昼夜 提交于 2019-11-29 00:46:30
问题 I have a job (call it BIGJOB) in Jenkins; several of the build steps are to trigger builds on other jobs (call them SMALLJOB) using the Parameterized Trigger Plugin then wait for them to complete. What I need to do is retrieve artifacts from the triggered build on SMALLJOB. Originally, I thought I could use the Copy Artifact Plugin to retrieve the artifacts from the "last build" of the triggered SMALLJOB. And this does work reliably when there is only one SMALLJOB running at a time. But I've

When using JUnit's @Parameterized, can I have some tests still run only once [duplicate]

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 20:54:42
问题 This question already has an answer here: Excluding a non param test in parameterized test class 9 answers I use @Parameterized in many cases to run tests on a number of permutations. This works very well and keeps the test-code itself simple and clean. However sometimes I would like to have some of the test-methods still run only once as they do not make use of the parameters, is there a way with JUnit to mark the test-method as "singleton" or "run-once"? Note: This does not concern running

Retrieve build number or artifacts of downstream build in Jenkins

落花浮王杯 提交于 2019-11-28 20:24:08
I have a job (call it BIGJOB) in Jenkins; several of the build steps are to trigger builds on other jobs (call them SMALLJOB) using the Parameterized Trigger Plugin then wait for them to complete. What I need to do is retrieve artifacts from the triggered build on SMALLJOB. Originally, I thought I could use the Copy Artifact Plugin to retrieve the artifacts from the "last build" of the triggered SMALLJOB. And this does work reliably when there is only one SMALLJOB running at a time. But I've got multiple BIGJOBs running, all triggering multiple SMALLJOBs so that using the "last build" is

Use reflection to create a generic parameterized class in Java

旧街凉风 提交于 2019-11-28 11:15:20
How can I use reflection to create a generic parameterized class in Java? I have public class SomeClass<T> { public SomeClass<T>() { } } and I need an instance of it. I've tried variations of Class c = Class.forName("SomeClass"); but could not find a syntax that would allow me to get an appropriately typed instance, like, say SomeType instance = (SomeType)Class.forName("SomeClass<SomeType>").createInstance(); So, how could I go about doing this? Java uses erasure-based generics (i.e., the type parameters are erased at runtime—for example, List<Integer> and List<String> are treated as the same

Returning an objects subclass with generics

妖精的绣舞 提交于 2019-11-28 08:25:21
With an abstract class I want to define a method that returns "this" for the subclasses: public abstract class Foo { ... public <T extends Foo> T eat(String eatCake) { ... return this; } } public class CakeEater extends Foo {} I want to be able to do things like: CakeEater phil = new CakeEater(); phil.eat("wacky cake").eat("chocolate cake").eat("banana bread"); Arguably banana bread would throw an IllegalArgumentException with the message "Not a cake!" public abstract class Foo<T extends Foo<T>> // see ColinD's comment { public T eat(String eatCake) { return (T)this; } } public class CakeEater

Prevention against SQL Injection in Hibernate

℡╲_俬逩灬. 提交于 2019-11-28 07:15:10
问题 I have used hibernate to interact with my database, now I wanted to make my database layer secure against SQL Injection, so I did some research and I found out that my queries should be parameterized , so does it mean if I just structure my HQL queries as: List mothers = session.createQuery( "select mother from Cat as cat join cat.mother as mother where cat.name = ?") .setString(0, name) .list(); Then it's parameterized and protected from SQL Injection, or is there something else which I need