This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="row"> | |
<div class="col l12"> | |
<%= widget %> | |
<label for="${property}" data-error="wrong" data-success="right">${label}</label> | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void runQuery(){ // This method does 3 things 1. Gets the db connection and 2. Runs the query 3. Closes the connection | |
Connection con = null; | |
try{ | |
Class.forName("com.mysql.jdbc.Driver"); | |
con=DriverManager.getConnection( "jdbc:mysql://localhost:3306/db","user","password"); | |
Statement stmt=con.createStatement(); | |
ResultSet rs=stmt.executeQuery("select * from emp"); | |
while(rs.next()) { | |
System.out.println(rs.getInt(1)+" "+rs.getString(2)+" "+rs.getString(3)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void runQuery(Connection connection){ | |
try{ | |
Statement stmt=con.createStatement(); | |
ResultSet rs=stmt.executeQuery("select * from table"); | |
while(rs.next()) { | |
System.out.println(rs.getInt(1)+" "+rs.getString(2)+" "+rs.getString(3)); | |
} | |
}catch(Exception e){ | |
//Handle exception | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. | |
int years = getYears(getDateOfBirth()); | |
int months = getMonths(getDateOfBirth()); | |
System.out.println("The age of the person is" + years + "years and "+months+" months"); | |
// 2. | |
Date dob = getDateOfBirth(); | |
int years = getYears(dob); | |
int months = getMonths(dob); | |
System.out.println("The age of the person is" + years + "years and "+months+" months"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//1. | |
for(User user:userList){ | |
int year = getCurrentYear(); | |
int days = getDaysInYear(year); | |
int dailySalary = user.getSalary()/days; | |
println "Daily salary of "+ user.getName() +" is "+dailySalary; | |
} | |
//2. | |
int year = getCurrentYear(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//... | |
refresh(){ | |
if(invoicingFeatureEnabled){ | |
Invoice.getInstance().refreshTaxes(this); | |
} | |
if(quotesAndProposolsEnabled){ | |
QuotesAndProposols.getInstance().refreshTaxes(); | |
} | |
if(salariesFeatureEnabled){ | |
IncomeTax.getInstance().refreshTaxes(this); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
public final class Broker { | |
private final Object mutex = new Object(); | |
static class CommonTopics { | |
private CommonTopics() { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.HashMap; | |
import java.util.Map; | |
public class Invoice implements Subscriber { | |
@Override | |
public void update(Broker.Context ctx) { | |
System.out.println("tax rates changed"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
refresh(){ | |
Broker.getInstance().sendMessage(Broker.CommonTopics.ON_TAX_CHANGE,Collections.emptyMap()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Reviewanswer getAnswer(int questionId) { | |
String sql = "select * from answers where questionid=:questionId"; | |
Map<String, Object> params = new HashMap<>(); | |
Reviewanswer answer = new Reviewanswer(); | |
params.put("questionId",questionId); | |
try { | |
answer = namedParameterJdbcTemplate.queryForObject(sql,params,Reviewanswer.class); | |
}catch (DataAccessException ex){ | |
Logger.getLogger(this.getClass().getName()).log(Level.ALL,ex.getLocalizedMessage()); | |
} |
OlderNewer