We use MySQL in production, and Derby for unit tests. Our pom.xml copies Derby version of persistence.xml before tests, and replaces it with the MySQL version in prepare-package phase:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<id>copy-test-persistence</id>
<phase>process-test-resources</phase>
<configuration>
<tasks>
<!--replace the "proper" persistence.xml with the "test" version-->
<copy
file="${project.build.testOutputDirectory}/META-INF/persistence.xml.test"
tofile="${project.build.outputDirectory}/META-INF/persistence.xml"
overwrite="true" verbose="true" failonerror="true" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
<execution>
<id>restore-persistence</id>
<phase>prepare-package</phase>
<configuration>
<tasks>
<!--restore the "proper" persistence.xml-->
<copy
file="${project.build.outputDirectory}/META-INF/persistence.xml.production"
tofile="${project.build.outputDirectory}/META-INF/persistence.xml"
overwrite="true" verbose="true" failonerror="true" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
The problem is, that if I execute mvn jetty:run it will execute the test persistence.xml file copy task before starting jetty. I want it to be run using the deployment version. How can I fix this?
We own a big site and we submitted it to digg.
Overnight, we had too many users added, up to 9000+.
We use Zend framework with one MySQL database. What actions should we take to make our server scale well?
Hello. I have the following php code that inserts data into XML and works correctly. However, I want to add an ID number like below
<CD id="xxxx">
My question is how can i add an ID into CD for this to work ? I use form to parse the id.
** the main code **
<?php
$CD = array(
'TITLE' => $_POST['title'],
'BAND' => $_POST['band'],
'YEAR' => $_POST['year'],
);
$doc = new DOMDocument();
$doc->load( 'insert.xml' );
$doc->formatOutput = true;
$r = $doc->getElementsByTagName("CATEGORIES")->item(0);
$b = $doc->createElement("CD");
$TITLE = $doc->createElement("TITLE");
$TITLE->appendChild(
$doc->createTextNode( $CD["TITLE"] )
);
$b->appendChild( $TITLE );
$BAND = $doc->createElement("BAND");
$BAND->appendChild(
$doc->createTextNode( $CD["BAND"] )
);
$b->appendChild( $BAND );
$YEAR = $doc->createElement("YEAR");
$YEAR->appendChild(
$doc->createTextNode( $CD["YEAR"] )
);
$b->appendChild( $YEAR );
$r->appendChild( $b );
$doc->save("insert.xml");
?>
the XML file
<?xml version="1.0" encoding="utf-8"?>
<MY_CD>
<CATEGORIES>
<CD>
<TITLE>NEVER MIND THE BOLLOCKS</TITLE>
<BAND>SEX PISTOLS</BAND>
<YEAR>1977</YEAR>
</CD>
<CD>
<TITLE>NEVERMIND</TITLE>
<BAND>NIRVANA</BAND>
<YEAR>1991</YEAR>
</CD>
</CATEGORIES>
</MY_CD>
I have add a custom plugin that insert custom tags into my tinyMCE editor of the format:
title
I want the custom tags to be rendered with some styles when viewed in the WYSIWYG view. I have seen one response to a similar question :
http://topsecretproject.finitestatemachine.com/2010/02/how-to-custom-tags-with-tinymce/
but this doesn't work - they tags are not stripped out but they are not styled either??
hi
i am having a link like below
<a href="#" onclick="window.open('http://www.twitter.com/home?status=Reading+Facebook share, Yahoo Buzz and Tweet this buttons for Blogger blogs+http://www.didiknow.com');">Tweet this</a>
i want to insert a php variable value inside for the status thing
like
<a href="#" onclick="window.open('http://www.twitter.com/home?status=$markme_ddesc">Tweet this</a>
how to do so?? please help me..
Hi ,
I have a string val = "14 22 33 48";
int matrix[5];
I need to insert each of the values in the string into the respective location in the array
Eg: matrix[0] = 14;
matrix[1] = 22;
matrix[2] = 33;
matrix[3] = 48;
How do I do this ?
Running XSD.exe on my xml to generate C# class. All works well except on this property
public DocumentATTRIBUTES[][] Document {
get {
return this.documentField;
}
set {
this.documentField = value;
}
}
I want to try and use CollectionBase, and this was my attempt
public DocumentATTRIBUTESCollection Document {
get {
return this.documentField;
}
set {
this.documentField = value;
}
}
/// <remarks/>
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
public partial class DocumentATTRIBUTES
{
private string _author;
private string _maxVersions;
private string _summary;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string author
{
get
{ return _author; }
set { _author = value; }
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string max_versions
{
get { return _maxVersions; }
set { _maxVersions = value; }
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string summary
{
get { return _summary; }
set { _summary = value; }
}
}
public class DocumentAttributeCollection : System.Collections.CollectionBase
{
public DocumentAttributeCollection() : base() { }
public DocumentATTRIBUTES this[int index]
{
get
{
return (DocumentATTRIBUTES)this.InnerList[index];
}
}
public void Insert(int index, DocumentATTRIBUTES value)
{
this.InnerList.Insert(index, value);
}
public int Add(DocumentATTRIBUTES value)
{
return (this.InnerList.Add(value));
}
}
However when I try to serialize my object using
XmlSerializer serializer = new XmlSerializer(typeof(DocumentMetaData));
I get the error:
{"Unable to generate a temporary class (result=1).\r\nerror CS0030:
Cannot convert type 'DocumentATTRIBUTES' to 'DocumentAttributeCollection'\r\nerror CS1502: The best overloaded method match for 'DocumentAttributeCollection.Add(DocumentATTRIBUTES)' has some invalid arguments\r\nerror CS1503: Argument '1': cannot convert from 'DocumentAttributeCollection' to 'DocumentATTRIBUTES'\r\n"}
the XSD pertaining to this property is
<xs:complexType>
<xs:sequence>
<xs:element name="ATTRIBUTES" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="author" type="xs:string" minOccurs="0" />
<xs:element name="max_versions" type="xs:string" minOccurs="0" />
<xs:element name="summary" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
Does cassandra replicates only on write procedure (with choosen consistency level)? Is there any auto-replicate option for absent nodes, if i want symetric data in every node?
If I plug in new node to cluster there is no auto replication - how to sync data from others nodes with new one?
If I want replication like multimaster (2 nodes) with slave backup (1 node) known from MySQL, what is the proper logic setup and manage that on cassandra (3 nodes)? How about two nodes?
I'm trying to insert/load javascript (e.g. prototype/jquery) into the iFrame generated by TinyMCE (tinymce.moxiecode.com) or YUI's text editor (http://developer.yahoo.com/yui/editor/) so as to better manipulate the objects/images/DIVs inside it.
Any thoughts?
I want to insert n elements into a map where n is known ahead of time. I do not want memory allocation at each insertion. I want all memory allocation at the beginning. Is there a way to do this? If so, how? Will writing some sort of memory allocator help?
I dont know much about classes, but have a reasonable knowledge of PHP/MySQL.
But why should I learn classes? I know they are important but what benefits can I see using them that I cant with?
I am getting exception: "Specific cast is not valid", here is the code
con.Open();
string insertQuery = @"Insert into Tender (Name, Name1, Name2) values ('Val1','Val2','Val3');Select Scope_Identity();";
SqlCommand cmd = new SqlCommand(insertQuery, con);
cmd.ExecuteNonQuery();
tenderId = (int)cmd.ExecuteScalar();
Hi,
I can not get the difference betwwn these statements? would you please help me,I have read some sample of select statements but I did not get these ones.
SELECT 'B' FROM T WHERE A = (SELECT NULL);
SELECT 'C' FROM T WHERE A = ANY (SELECT NULL);
SELECT 'D' FROM T WHERE A = A;
I use MySQL
During a SSIS load, when an employee table is getting updated, locking comes into effect.
However, have disabled lock escalation on the table using the following statements:
ALTER TABLE dbo.Employee SET (LOCK_ESCALATION = DISABLE)
DBCC TRACEON (1211,-1)
However, the table (object) does get locked and is held for almost an hour. The total no. of updates (insert, update, delete statements) are approx 200,000
Why are there so many Database management systems? I am not an DB expert and I've never thought about using another Database other than mySQL.
Programming languages offer different paradigms, so it makes sense to choose a specific language for your purpose.
Question
What are the factors in choosing a specific Database management system ?
I want to run a Firebird stored procedure from a batch file or similar on a desktop. The stored procedure contains insert statements and update statements with if possible parameters that I would like to pass.
Any ideas or other suggestions would be appreciated.
I was following Hibernate: Use a Base Class to Map Common Fields and openjpa inheritance tutorial to put common columns like ID, lastModifiedDate etc in base table.
My annotated mappings are as follow :
BaseTable :
@MappedSuperclass
public abstract class BaseTable {
@Id
@GeneratedValue
@Column(name = "id")
private int id;
@Column(name = "lastmodifieddate")
private Date lastModifiedDate;
...
Person table -
@Entity
@Table(name = "Person ")
public class Person extends BaseTable implements Serializable{
...
Create statement generated :
create table Person (id integer not null auto_increment, lastmodifieddate datetime, name varchar(255), primary key (id)) ;
After I save a Person object to db,
Person p = new Person();
p.setName("Test");
p.setLastModifiedDate(new Date());
..
getSession().save(p);
I am setting the date field but, it is saving the record with generated ID and LastModifiedDate = null, and Name="Test".
Insert Statement :
insert into Person (lastmodifieddate, name) values (?, ?)
binding parameter [1] as [TIMESTAMP] - <null>
binding parameter [2] as [VARCHAR] - Test
Read by ID query :
When I do hibernate query (get By ID) as below, It reads person by given ID.
Criteria c = getSession().createCriteria(Person.class);
c.add(Restrictions.eq("id", id));
Person person= c.list().get(0);
//person has generated ID, LastModifiedDate is null
select query select person0_.id as id8_, person0_.lastmodifieddate as lastmodi8_, person0_.name as person8_ from Person person0_
- Found [1] as column [id8_]
- Found [null] as column [lastmodi8_]
- Found [Test] as column [person8_]
ReadAll query :
//read all
Query query = getSession().createQuery("from " + Person.class.getName());
List allPersons=query.list();
Corresponding SQL for read all
select query select person0_.id as id8_, person0_.lastmodifieddate as lastmodi8_, person0_.name as person8_ from Person person0_
- Found [1] as column [id8_]
- Found [null] as column [lastmodi8_]
- Found [Test] as column [person8_]
- Found [2] as column [id8_]
- Found [null] as column [lastmodi8_]
- Found [Test2] as column [person8_]
But when I print out the list in console, its being more weird. it is selecting List of Person object with
ID fields = all 0 (why all 0 ?)
LastModifiedDate = null
Name fields have valid values
I don't know whats wrong here. Could you please look at it?
FYI,
My Hibernate-core version : 4.1.2, MySQL Connector version : 5.1.9 .
In summary, There are two issues here
Why I am getting All ID Fields =0 when using read all?
Why the LastModifiedDate is not being inserted?
i have this querystring that shall open up my page.
http://www.a1-one.com/[email protected]&stuid=123456
Now when this page loads, on page_load, I want to pick up email and stuid in two different variables. So I can use them to insert into my database (sql server)
how can this be done in vb.net
I'm using Python to read and write SAS datasets, using pyodbc and the SAS ODBC drivers. I can load the data perfectly well, but when I save the data, using something like:
cursor.execute('insert into dataset.test VALUES (?)', u'testing')
... I get a pyodbc.Error: ('HY004', '[HY004] [Microsoft][ODBC Driver Manager] SQL data type out of range (0) (SQLBindParameter)') error.
The problem seems to be the fact I'm passing a unicode string; what do I need to do to handle this?
simple query,but it's giving me a headache, i need a division to be updated with a changed session variable each time a user clicks on a name,i figured i'd use .html() using jquery to update the division, i don't know if you can do this, but here goes:
$("#inner").html('<?php
session_start();
if(file_exists($_SESSION['full'])||file_exists($_SESSION['str'])){
if(file_exists($_SESSION['full']))
{
$full=$_SESSION['full'];
$handlle = fopen($full, "r");
$contents = fread($handlle, filesize($full));
fclose($handlle);
echo $contents;
echo '<script type="text/javascript" src="jquery-1.8.0.min (1).js">';
echo '</script>';
echo '<script type="text/javascript">';
echo 'function loadLog(){
var oldscrollHeight = $("#inner").attr("scrollHeight") - 20;
$.ajax({
url: \''.$_SESSION['full'].'\',
cache: false,
success: function(html){
$("#inner").html(html); //Insert chat log into the #chatbox div
var newscrollHeight = $("#inner").attr("scrollHeight") - 20;
if(newscrollHeight > oldscrollHeight){
$("#inner").animate({ scrollTop: newscrollHeight }, \'normal\'); //Autoscroll to bottom of div
}
},
});
}
setInterval (loadLog, 2500);';
echo '</script>';
}
else
{
$str=$_SESSION['str'];
if(file_exists($str))
{
$handle = fopen($str, 'r');
$contents = fread($handle, filesize($str));
fclose($handle);
echo $contents;
$full=$_SESSION['full'];
$handlle = fopen($full, "r");
$contents = fread($handlle, filesize($full));
fclose($handlle);
echo $contents;
echo '<script type="text/javascript" src="jquery-1.8.0.min (1).js">';
echo '</script>';
echo '<script type="text/javascript">';
echo 'function loadLog(){
var oldscrollHeight = $("#inner").attr("scrollHeight") - 20;
$.ajax({
url: \''.$_SESSION['str'].'\',
cache: false,
success: function(html){
$("#inner").html(html); //Insert chat log into the #chatbox div
var newscrollHeight = $("#inner").attr("scrollHeight") - 20;
if(newscrollHeight > oldscrollHeight){
$("#inner").animate({ scrollTop: newscrollHeight }, \'normal\'); //Autoscroll to bottom of div
}
},
});
}
setInterval (loadLog, 2500);';
echo '</script>';
}
}
}
?>');
is that legal, if not, how would i accomplish this?
Hi All,
i am having a user table which has desname as FK referring to des table ,i am trying to add desname in user but i am gettng Cannot add or update a child row: a foreign key constraint fails error.
desname is prepopulated and i am selected the same for he user.Where i am doing wrong
I ma using mysql and hibernate hbm
I need to use a serializable type in hibernate (to store a Subject (security)) All this works fine.
I just need to know what the underlying database types are for the following databases:
MSSQL - I used 'image'
db2 -
postgre -
mysql -
Thanks..
For whatever reason, my cucumber is using my _development db instead of my _test db.
How do I change that?
This is what my database.yml says
test:
adapter: mysql
encoding: utf8
but i get the error database configuration does not specify adapter