Skip to content

Instantly share code, notes, and snippets.

@shaik2many
shaik2many / solr-delete-exactmatch
Created November 12, 2014 18:22
solr delete specific content
http://abc.com/seek/comet-binary/update?stream.body={%22delete%22:{%22query%22:%22text:\%22503%20Service%20Temporarily%20Unavailable\%22%22}}&commit=true
http://abc.com/seek/comet-binary/update?stream.body={"delete":{"query":"*:*"}}&commit=true
http://abc.com/seek/comet-binary/update?stream.body={"delete":{"query":"text:\"503 Service Temporarily\""}}&commit=true
@shaik2many
shaik2many / java-file-write-performance.java
Created November 7, 2014 17:31
java file write performance
/**
* http://stackoverflow.com/questions/1062113/fastest-way-to-write-huge-data-in-text-file-java
*
* I have to write huge data in text[csv] file. I used BufferedWriter to write the data and it
* took around 40 secs to write 174 mb of data. Is this the fastest speed java can offer?
* bufferedWriter = new BufferedWriter ( new FileWriter ( "fileName.csv" ) );
*
* You might try removing the BufferedWriter and just using the FileWriter directly. On a modern system
* there's a good chance you're just writing to the drive's cache memory anyway.
* It takes me in the range of 4-5 seconds to write 175MB (4 million strings) -- this is on a dual-core 2.4GHz Dell
@shaik2many
shaik2many / java-sysout-file.java
Last active August 29, 2015 14:08
java sysout file
public class SysOutToFile {
public void test() {
String line = System.getProperty("line.separator");
PrintStream out = new PrintStream(new FileOutputStream("C:/migration-out.txt"));
PrintStream err = new PrintStream(new FileOutputStream("C:/migration-err.txt"));
System.setOut(out);
System.setErr(err);
out.flush();
err.flush();
@shaik2many
shaik2many / java-thread.java
Created November 7, 2014 17:21
java threading
public class TestThread {
public static void main(String[] args) {
String[] workitems = {"Quran", "Coummnity Service", "Teaching", "Business"};
for (String name : workitems) {
new Thread(new DoWork(name)).start();
}
System.out.println("Done....");
}
}
@shaik2many
shaik2many / java-ascii-strip
Created October 20, 2014 18:10
Strip ASCII
import java.util.regex.Pattern;
import org.apache.commons.lang.StringUtils;
public class StringUtil {
private static final Pattern REGEX_PATTERN = Pattern.compile("[^\\p{ASCII}]+");
public static String stripNonAsciiChars(String input, String repalceCharWith) {
return (StringUtils.isBlank(input)) ? null :
REGEX_PATTERN.matcher(input).replaceAll(repalceCharWith);
@shaik2many
shaik2many / oracle merge.sql
Last active August 29, 2015 14:04
oracle merge
merge into tims_idr_agent t
using (select 1 from DUAL) s
on (t.id = p_id AND t.audit_cycle = p_audit_cycle)
when matched then
update set t.name = 'Alan1',t.phone = '-2932x',t.email = 'Alan@v1',t.category = 'Domestic1'
when not matched THEN
INSERT (audit_cycle,ID,NAME,phone,email,category)
VALUES(p_audit_cycle,p_id,p_name,p_phone,p_email,p_category);
- insertion and retrieval of the unique id is done in two steps(two db calls) if you were to implement using java approach. this can be simplied if you were to implement it in stored procedure.
- Maintenance of any structural changes are always easier at oracle/db end when compared to doing it at java end
- code is much cleaner if done at db end rather than doing it at java end
- perfect use case which is in favor of keeping the save logic at the DB end is
Multiple saves in One Single page
Project -> Project
Project -> ProjectBusiness
Project -> businesses
Project -> country
<%
String filename = "/sanvol/app/folder1";
out.println(filename);
java.io.File f = new java.io.File(filename);
out.println(f.isDirectory());
javax.naming.InitialContext ic = new javax.naming.InitialContext();
javax.sql.DataSource ds = (javax.sql.DataSource) ic.lookup("java:oasDS");
out.println(ds);
exec dbms_stats.gather_table_stats (ownname => 'abcDBA01',tabname => 't_table_name',estimate_percent=> 100,cascade => true);
create index i4_mvtable on mvtable(c1||c2||c3, c4, c3);
create index i5_mvtable on mvtable(c1, c4, c3);